Subject: Re: Exploding a string into a list of character atoms? From: Erik Naggum <email@example.com> Date: 1996/09/24 Newsgroups: comp.lang.lisp Message-ID: <firstname.lastname@example.org> [Stefan Bamberger] | > Is there a function to take a string like "string" and return | > the list (S T R I N G)? (I am using GCL.) Thanks for any help! | | (defun explode (item) | (flet ((*care-string (thing) | (format nil "~a" thing)) | (*create-symbol (charac) | (intern (string (char-upcase charac)))) | ) | (let ((str (*care-string item)) | (erglist nil) | ) | (dotimes (i (length str) (nreverse erglist)) | (push (*create-symbol (char str i)) | erglist) | ) | ))) | | That's what I use to do that. you do? really? I already mentioned this: (coerce "string" 'list) => (#\s #\t #\r #\i #\n #\g) but if you insist om making symbols: (defun explode (string) (mapcar #'(lambda (char) (intern (string (char-upcase char)))) (coerce string 'list))) (explode "string") => (s t r i n g) a simple comparison using CMUCL at (optimize (speed 3)) says that your function conses 848 bytes, while mine conses 208 bytes, that your function requires 531 µs (microseconds) of CPU time on a 50MHz SPARC 2, while mine requires 293 µs. compared to this, (coerce "string" 'list) takes 101 µs and conses 56 bytes, basically the 6 cons cells. YMMV. #\Erik -- Those who do not know Lisp are doomed to reimplement it.