string to list

stevej

Usenet Archive
Joined
Nov 4, 2000
Messages
15
Reaction score
0
Hello All

How do I convert a string "9 10 11 12" into a list (9 10 11 12). I'd thought this would be easy but all cominations of ascii, vl-string->list, etc don't seem to be working. Can anyone help please?

Steve
 
It's much easier than you think. Suppose varable str holds the string containing your row of numbers, (read (strcat "(" str ")")) converts this into a list.

With friendly greetings, M. Moolhuysen.
 
Kevin,

Thanks for that, but it didn't actually matter whether the list returned was (9 10 11 12) or ("9" "10" "11" "12"), I'd just assumed the former would be easier. Would there be any advantages using either solution over the other?
 
It depends on how you need to store the data. If you need them to stay as strings then I'd use one of the string parsing utilities. If you need them to be turned into a list of numbers I'd use the other method posted.

stevej said:
Kevin,
Thanks for that, but it didn't actually matter whether the list returned
was (9 10 11 12) or ("9" "10" "11" "12"), I'd just assumed the former would be easier. Would there be any advantages using either solution over the other?
 
Back
Top