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
Todd McLaughlin <·····@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.
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?