Help! Convert string to list 
Author Message
 Help! Convert string to list

Hi,

I need a simple way to convert a string to a list for a program I am
working on.
(create-list "1 2 3 4 5 #my-func")
should return (1 2 3 4 5 #my-func)

Please help!
Thanks



Fri, 26 Apr 2002 03:00:00 GMT  
 Help! Convert string to list

Quote:

>Hi,

>I need a simple way to convert a string to a list for a program I am
>working on.
>(create-list "1 2 3 4 5 #my-func")
>should return (1 2 3 4 5 #my-func)

(defun create-list (string)
  (read-from-string (concatenate 'string "(" string ")")))

However, I'm not sure what you expect #my-func to be.  # is a special macro
character in Common Lisp and many other Lisp dialects.  If you want that to
be read in as a symbol whose name is "#MYFUNC", you'll need to make a
custom readtable that changes the syntax of #\# to a constituent rather
than a macro character.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Fri, 26 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Convert string of words to list of strings

2. Converting string from to a list of tokens...?

3. Converting a list to a string

4. Convert list of Ascii codes to a string?

5. Convert type String to List of single Characters

6. converting a string to a list

7. Converting a list to a string

8. convert string to list of symbols

9. Converting a string to a list

10. converting list back to string

11. converting a num or list to a string

12. ConfigParser & converting strings to lists

 

 
Powered by phpBB® Forum Software