←back to thread

Hofstadter on Lisp (1983)

(gist.github.com)
372 points Eric_WVGG | 1 comments | | HN request time: 0.256s | source
Show context
timonoko ◴[] No.41865389[source]
Maclisp goodness:

  (compress (reverse (explode x)))
Elisp much improved:

  (defun explode (x)
    (if (symbolp x) (setq x (symbol-name x)))
    (string-to-list x))
  (defun compress (x) (concat x))
replies(3): >>41865620 #>>41865873 #>>41869520 #
1. g19205 ◴[] No.41869520[source]
this is how explode behaves on a lisp machine:

    (defun explode (x)
       (mapcar (lambda (x)
          (intern (char-to-string x)))
        (string-to-list (prin1 x))))
turning character into symbol seems natural, because then you are reducing your needed function space even more. I'm surprised the original operated on prin1 output, not sure what the logic behind that is. on a lisp machine (zl:explode "foo") gives me '(|"| |f| |o| |o| |"|)