String Lists

Started by Jeremy Dunn, January 10, 2005, 07:14:51 AM

Previous topic - Next topic

Jeremy Dunn

In the Python language one can write long lists of strings without having to type all the quotation marks. I would like a function that would do the following



(str cat dog rat bat) -> ("cat" "dog" "rat" "bat")



How can one accomplish this in NewLISP? Of course strings with spaces would not be allowed.

Sammo

#1
> (map string '(cat dog rat bat))

("cat" "dog" "rat" "bat")



> (define-macro (str) (map string (args)))

(lambda-macro () (map string (args)))



> (str cat dog rat bat)

("cat" "dog" "rat" "bat")

eddier

#2
I know Perl uses:


qw/cat dog rat bat/

Just curious, what is it in Python

Sammo

#3
Oh, and strings with embedded spaces may simply be quoted.



> (str "string with spaces" cat rat bat hat sat mat fat gat gnat pat vat)

("string with spaces" "cat" "rat" "bat" "hat" "sat" "mat" "fat" "gat"  "gnat" "pat" "vat")

Jeremy Dunn

#4
Thank you one and all.