Created
September 27, 2013 09:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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