Skip to content

Instantly share code, notes, and snippets.

@tkych
Created September 27, 2013 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkych/6726391 to your computer and use it in GitHub Desktop.
Save tkych/6726391 to your computer and use it in GitHub Desktop.
Print "Hello World" to stdout without numbers, characters and strings in Common Lisp. c.f. http://codeiq.hatenablog.com/entry/2013/09/25/163547
#!/usr/local/bin/sbcl --script
;; Print "Hello World" to stdout without numbers, characters and strings in Common Lisp.
;;
;; c.f. http://codeiq.hatenablog.com/entry/2013/09/25/163547
;;
;; Usage:
;; $ chmod u+x hello-world.lisp
;; $ ./hello-world.lisp
(with-open-file (in #p"./hello-world.lisp")
(read-line in) ; omit shebang line
(read in) ; omit this with-open-file form
(flet ((count-nest (parentheses)
(loop for ps = (cdr parentheses) ; remove quote
then (car ps)
until (null ps)
sum 1)))
(loop for ps = (read in nil :eof)
until (eq ps :eof)
collect (count-nest ps) into acc
finally (princ (map 'string #'code-char acc)))))
;; (code-char 72) => #\H
'(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 101) => #\e
'((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 108) => #\l
'(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 108) => #\l
'(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 111) => #\o
'((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 32) => #\Space
'(((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))
;; (code-char 87) => #\W
'((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 111) => #\o
'((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 114) => #\r
'(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 108) => #\l
'(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 100) => #\d
'(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;; (code-char 10) => #\Newline
'(((((((((())))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment