Given an expression '(lambda (x) x) How can I translate this into a string. I thought symbol->string will do the job but no it cant not a symbol.
e.g for a macro to-string: (to-string (lambda(x) x)) this should return >> "(lambda (x) x)"
Any ideas folks Thanks
Standard Scheme (at least in the R5RS sense) has no way of doing this, so if you want portable code, you need to walk the structure yourself. Tedious, but not too complicated (even for dotted lists).
But if you just want some working version, then you should look in your implementation's manual and search for the way to do this. The answer will almost always be simple, for example, in PLT Scheme you'd use (format "~s" '(lambda ...))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With