* Myriam Abramson <········@osf1.gmu.edu>
|
| Could somebody please show me how to loop through a comma-delimited
| string the right way.
With the help of SPLIT-SEQUENCE
(<URL:http://ww.telent.net/cliki/SPLIT-SEQUENCE>):
(split-sequence #\, "foo,bar ,baz, foobar , barbaz,")
=> ("foo" "bar " "baz" " foobar " " barbaz" "")
--
Vebjorn Ljosa
Vebjorn Ljosa <·····@ljosa.com> writes:
> * Myriam Abramson <········@osf1.gmu.edu>
> |
> | Could somebody please show me how to loop through a comma-delimited
> | string the right way.
>
> With the help of SPLIT-SEQUENCE
> (<URL:http://ww.telent.net/cliki/SPLIT-SEQUENCE>):
>
> (split-sequence #\, "foo,bar ,baz, foobar , barbaz,")
> => ("foo" "bar " "baz" " foobar " " barbaz" "")
For what it's worth, I think this is a completely wrong way of doing
this. It conses unnecessarily, and can generally get in the way of
neat tricks. I use a utility to iterate through the string, and call
my code with the start and end of the substrings.
I posted my utilities to do this here:
http://groups.google.com/groups?q=group:comp.lang.lisp+splitting-vector&hl=en&rnum=1&selm=xcvvghhpw95.fsf%40conquest.OCF.Berkeley.EDU
(Note the messed up error message for call-splitting-vector, when
start < 0, oops)
--
/|_ .-----------------------.
,' .\ / | No to Imperialist war |
,--' _,' | Wage class war! |
/ / `-----------------------'
( -. |
| ) |
(`-. '--.)
`. )----'