Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: arthur@altdorf.ai.mit.EDU ("Arthur Gleckler") Newsgroups: comp.lang.scheme.c Subject: list-to-string conversion Message-ID: <9103111501.AA03677@bloom-beacon.MIT.EDU> Date: 11 Mar 91 14:30:58 GMT References: <2372@tuvie.UUCP> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: arthur@zurich.ai.mit.edu Organization: The Internet Lines: 36 Date: 9 Mar 91 09:38:51 GMT From: walter@vlsivie.tuwien.ac.at Organization: Vienna University of Technology, Dept. of VLSI-Design Newsgroups: comp.lang.scheme.c Sender: info-cscheme-request@altdorf.ai.mit.edu Does anybbody know how to construct a function "list->string" for MIT Scheme vers 7.0 ? It should work as follows: (list->string '((a 1) (b 2))) => "((a 1) (b 2))" I can find many conversion functions like number->string, symbol->string etc. but can't use that for my trivial seeming function. I would appreciate any comments to that problem walt Walter Eder Dept. of VLSI-Design, University Vienna, Austria Email: walter@vlsivie.tuwien.ac.at The procedure WITH-OUTPUT-TO-STRING is good for this type of problem. Given a a procedure of no arguments (a "thunk"), it invokes the thunk, capturing all its output in a string. This string is returned as the value of the call to WITH-OUTPUT-TO-STRING: (with-output-to-string (lambda () (display '((a 1) (b 2))))) ;Value 1: "((a 1) (b 2))"