Subject: Re: list to string etc. From: Erik Naggum <nobody@naggum.no> Date: 1996/12/04 Newsgroups: comp.lang.lisp Message-ID: <3058728342774689@naggum.no> * Thomas Kaeufl | perhaps the use of PRINC-TO-STRING might be preferred in | | > (make-symbol (format nil "~{~S~}" <list of symbols>)) | | or | | > (intern (format nil "~{~S~}" <list of symbols>)) | | In Lisp always use the function which is just appropriate for your | task. FORMAT is to big. using this argument, we should be using C or assembly language. `format' is a lot more efficient than the uninitiated believe. if performance is your pet peeve, the `formatter' function parses the control string normally to `format' and returns a function that can be used in place of the control string, in which case `format' only calls that function. this function will be compiled if you stuff it in a variable: (defvar *symbol-list-formatter* (formatter "~{~S~}")) ... (format t *symbol-list-formatter* <list of symbols>) ... e.g., I get this from Bruno Haible's CLISP. (I couldn't get CMUCL to want to print the whole function it generated -- apparently *print-level* is bound to some ridiculously low value when printing the internals of an unprintable object of the interpreted-function persuasion. suggestions?) (formatter "~{~S~}") => #<closure :lambda (stream #:arg686 &rest #:args680) (declare (ignorable stream)) (declare (ignorable #:arg686 #:args680)) (apply #'(lambda (&rest #:args685) (declare (ignorable #:args685)) (block nil (tagbody system::l (when (endp #:args685) (return)) (prin1 (pop #:args685) stream) (go system::l)))) #:arg686) #:args680> this is the code that `format' actually runs. however, if you wanted a version that didn't use `format' and could only be used with symbols whose names are exactly one character long, this would be "better": (map 'string (lambda (symbol) (char (symbol-name symbol) 0)) <list of symbols>) as I had confirmed recently, the chance that this produces code that equals the efficiency of the `format' call with a `formatter'-supplied function is high. #\Erik -- Please address private replies, only, to "erik". Junk mail, spam, stupid flames, courtesy copies, etc, should be sent to "nobody".