From ... From: Erik Naggum Subject: Re: list to string etc. Date: 1996/12/04 Message-ID: <3058728342774689@naggum.no>#1/1 X-Deja-AN: 202385965 references: <329C9918.46B@tip.nl> <583vl8$7db@nz12.rz.uni-karlsruhe.de> organization: Naggum Software; +47 2295 0313; http://www.naggum.no newsgroups: comp.lang.lisp * Thomas Kaeufl | perhaps the use of PRINC-TO-STRING might be preferred in | | > (make-symbol (format nil "~{~S~}" )) | | or | | > (intern (format nil "~{~S~}" )) | | 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* ) ... 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~}") => # 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)) ) 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".