More on reading

Q&A's, tips, howto's

More on reading

Postby Bat » Fri Oct 10, 2003 4:18 pm

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.
Posts: 10
Joined: Fri Oct 10, 2003 3:38 pm

Postby eddier » Fri Oct 10, 2003 4:47 pm

(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)

Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Lutz » Fri Oct 10, 2003 11:23 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.

Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests