The expression '(lambda (x) x)
is a quoted list.
The expression (lambda (x) x)
is some kind of compiled, opaque, executable, internal object of the runtime.
symbol->string
simply converts a symbol to a string, which is a sequence of characters.
If you're working with a list, you can simply walk the list and print the individual components out. In fact (write '(lambda (x) x))
will simply print the list out.
Many schemes have something akin to (with-output-to-string ... )
that returns a string of all the output written to the standard port.
However, if you do (write (lambda (x) x))
, you'll get who knows what. You'll get whatever the implementation provides when dumping an executable function type. Some may print a "disassembly" showing the source code. Others may simply print #function
or something equally useless.
In short, if you just want to print out a list, there are all sorts of mechanisms for that.
If you want to print out the source code of a compiled function, that's a completely different problem, very implementation dependent, and may well be impossible.