newLISP Fan Club

Forum => newLISP in the real world => Topic started by: Bat on October 10, 2003, 09:18:52 AM

Title: More on reading
Post by: Bat on October 10, 2003, 09:18:52 AM
I Common Lisp you can transform a string into a list of atoms, such as:

"hi how are you" -> (hi how are you).

You just 'read-input-from-string' the original string and cons the atoms into a list.  For instance, see (read-sentence) in Winston 3rd ed., p. 426.



How to do this in Newlisp ?

I imagine this can be done with regex, but since I dont know Perl, I cannot be sure.
Title:
Post by: eddier on October 10, 2003, 09:47:48 AM
(parse "hi how are you") -> (how are you)



If you want a certain string to delimate the text say ",":



(parse "hi,how,are,you" ",") -> (how are you)



Eddie
Title:
Post by: Lutz on October 10, 2003, 04:23:28 PM
actually that would be:



(map symbol (parse "hello how are you")) => (hello how are you)



because 'parse' does just the string split:



(parse "hello how are you") => ("hello" "how" "are" "you")



read also my comment on the other thread: "how about (read)", which is related.



Lutz