Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!agate!linus!linus!thelonius!john From: john@thelonius.mitre.org (John D. Burger) Newsgroups: comp.lang.lisp Subject: Re: String to List function! Message-ID: <1991May24.221239.21903@linus.mitre.org> Date: 24 May 91 22:12:39 GMT Sender: news@linus.mitre.org (News Service) Organization: The MITRE Corporation, Bedford, MA 01730 Lines: 26 Nntp-Posting-Host: thelonius.mitre.org bcheung@cs.concordia.ca (CHEUNG yik-chi) writes: How can I transfer a string like "abc ( 1 2 3) def" to (abc (1 2 3) def) Here's an extremely egregious version: (defun cheesy-string-to-list (string) (values (read-from-string (concatenate 'string "(" string ")")))) And here's one that's not a memory hog: (defun string-to-list (string) (with-input-from-string (stream string) (let ((eof stream) (result '())) (loop (let ((object (read stream nil eof))) (if (eq object eof) (return (nreverse result)) (push object result))))))) -- John Burger john@mitre.org "You ever think about .signature files? I mean, do we really need them?" - alt.andy.rooney