Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(explode 'list) ?

1 view
Skip to first unread message

Todd McLaughlin

unread,
Oct 7, 1998, 3:00:00 AM10/7/98
to

My goal is:

(MY LIST) -> (M Y #\space L I S T)

I'm obviously looking for an explode func. I found coerce
but that's only for strings and I couldn't find a way to
convert a list with spaces in it to a string. I could write
a function that took each symbol out of the list and converte
it but I was hoping for a more elegant solution.

Note: It doesn't matter how the space is represented but it
does need to be included in the result.

I know I'll feal stupid when I hear the answer but lay it
on anyway. Thanks.

Todd

Kent M Pitman

unread,
Oct 7, 1998, 3:00:00 AM10/7/98
to
Todd McLaughlin <to...@waltz.rahul.net> writes:

> I'm obviously looking for an explode func. I found coerce
> but that's only for strings and I couldn't find a way to
> convert a list with spaces in it to a string.

(defun explode (obj) (coerce (prin1-to-string obj) 'list))

There's also princ-to-string if you'd prefer that.

Marc Dzaebel

unread,
Oct 7, 1998, 3:00:00 AM10/7/98
to
Todd McLaughlin wrote:
> My goal is:
> (MY LIST) -> (M Y #\space L I S T)

(defun explode(l)
(if(atom l)
(loop for c across(princ-to-string l)
collect(intern(string c)))
(loop for es on l append(explode(car es))
if(cdr es)collect #\space)))

(explode '(my list 2 "drei"))
-> (M Y #\space L I S T #\space 2 #\space D R E I)

I don't how you like basic constants to be transformed.
Is this what you want?

0 new messages