Skip to content

Instantly share code, notes, and snippets.

@letoh
Last active August 29, 2015 14:05
Show Gist options
  • Save letoh/5b4937008f9851a97add to your computer and use it in GitHub Desktop.
Save letoh/5b4937008f9851a97add to your computer and use it in GitHub Desktop.
;; goal in elisp
;; emacs -batch -Q -l goal.el
(defmacro g (&rest al)
`(concat "g"
(apply 'concat
(mapcar (lambda (o)
(if (null o) "o"
(if (listp o) (car o)
"")))
',al))))
;; test
(defmacro test-g (&rest s)
`(mapc (lambda (s)
(print (eval s)))
',s)
)
(test-g
(g("al"))
(g()("al"))
(g()()("al"))
(g()()()("al"))
)
# http://ideone.com/ZHpT4j
g = lambda s = None, r = 'g': (lambda s = None: g(s, r + 'o')) if s is None else r + s
print g("al")
print g()("al")
print g()()("al")
print g()()()("al")
print g()()()()("al")
f = 'g'
while True:
print eval(f + '("al")')
f += '()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment