Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

String to list

3 views
Skip to first unread message

Yuri Ronin

unread,
Nov 14, 2002, 10:46:57 AM11/14/02
to
Hello,
I am rather new in lisp, and I have a next question:
How can I convert "(3 4)" to list?
Thanx a lot, Yuri


Martti Halminen

unread,
Nov 14, 2002, 10:47:44 AM11/14/02
to

(read-from-string "(3 4)")

- Better make sure *read-eval* is nil, if your data comes from an
untrusted source.

--

Marco Antoniotti

unread,
Nov 14, 2002, 11:31:56 AM11/14/02
to

"Yuri Ronin" <su...@t2.technion.ac.il> writes:

> Hello,
> I am rather new in lisp, and I have a next question:
> How can I convert "(3 4)" to list?

Check out the function `read-from-string'

cl-prompt> (read-from-string "(3 4)")
(3 4)
5

Note that the function returns 2 values: (1) the object read and (2)
"the index of the first character in the bounded string that was not
read." (from the ANSI spec).

Cheers

--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
715 Broadway 10th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.

Kaz Kylheku

unread,
Nov 14, 2002, 2:22:04 PM11/14/02
to
"Yuri Ronin" <su...@t2.technion.ac.il> wrote in message news:<ar0ghg$f5n$1...@news.iucc.ac.il>...

> Hello,
> I am rather new in lisp, and I have a next question:
> How can I convert "(3 4)" to list?

(read-from-string "(3 4)")

For more info, like how to trap errors, see:

http://www.lispworks.com/reference/HyperSpec/Body/f_rd_fro.htm

0 new messages