Skip to content

Instantly share code, notes, and snippets.

@stibear
Last active December 22, 2015 06:58
Show Gist options
  • Save stibear/6434691 to your computer and use it in GitHub Desktop.
Save stibear/6434691 to your computer and use it in GitHub Desktop.
generate "Hello World" without including any literal.
(defmacro def-print-string (name)
`(defun ,name ()
(let ((one (count t'(t))))
(print
(coerce
(mapcar #'code-char
(list
,@(loop :for i :across (string name)
:collect
`(+ ,@(loop :for j := (char-code i) :then (floor j #.(count t'(t t)))
:for to-collect := 'one :then `(ash ,to-collect one)
:until (zerop j)
:unless (zerop (mod j #.(count t'(t t))))
:collect to-collect)))))
'string)))))
(def-print-string |Hello World|)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment