From: John D. Burger
Subject: Re: String to List function!
Date:
Message-ID: <1991May24.221239.21903@linus.mitre.org>
·······@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 ····@mitre.org
"You ever think about .signature files? I mean, do we really need them?"
- alt.andy.rooney