ccc31807 <cartercc@gmail.com> wrote:
+---------------
| How do you convert a string to a list in CL? Is there a CL equivalent
| to Perl's split() function, or Java's StringTokenizer class?
+---------------
Others have mentioned the SPLIT-SEQUENCE package & function
[almost identical to Perl's split()], but just so you know,
CL also has the ultimate fine-grained split builtin: ;-}
> (coerce "This is a string." 'list)
(#\T #\h #\i #\s #\ #\i #\s #\ #\a #\ #\s #\t #\r #\i #\n #\g #\.)
> (subseq * 8 16)
(#\a #\ #\s #\t #\r #\i #\n #\g)
> (coerce * 'string)
"a string"
>
-Rob
p.s. Of course, SUBSEQ works directly on strings, too:
> (subseq "This is a string." 8 16)
"a string"
>
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607