From: CHEUNG yik-chi
Subject: String to List function!
Date: Fri, 24 May 1991 21:05:56 +0000
Message-ID: <326@daily-planet.concordia.ca> Hi,
Can any one show me a way to do the following function.
How can I transfer a string like "abc ( 1 2 3) def" to
(abc (1 2 3) def)
thanks
Benjamin Y.C Cheung. From: Vance Maverick
Subject: Re: String to List function!
Date: Fri, 24 May 1991 21:50:50 +0000
Message-ID: <1991May24.215050.7088@agate.berkeley.edu> <cl> (defun string-to-list (string)
(with-input-from-string (strm (concatenate 'string "(" string ")"))
(read strm)))
STRING-TO-LIST
<cl> (string-to-list "abc ( 1 2 3) def")
(ABC (1 2 3) DEF)
<cl> From: Erann Gat
Subject: Re: String to List function!
Date: Fri, 24 May 1991 22:21:46 +0000
Message-ID: <1991May24.222146.980@elroy.jpl.nasa.gov> (defun string->list (s) (read-from-string (concatenate 'string "(" s ")"))) From: Tim Weinrich
Subject: Re: String to List function!
Date: Tue, 28 May 1991 19:39:54 +0000
Message-ID: <WEINRICH.91May28153954@clarity.Princeton.EDU> From: ········@cork.Berkeley.EDU (Vance Maverick)
<cl> (defun string-to-list (string)
(with-input-from-string (strm (concatenate 'string "(" string ")"))
(read strm)))
STRING-TO-LIST
<cl> (string-to-list "abc ( 1 2 3) def")
(ABC (1 2 3) DEF)
<cl>
I strongly recommend putting an ERRSET (or your dialect's
equivalent) around that READ for most applications.
Otherwise, a very good answer.
Twinerik