Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
Created March 19, 2025 04:42
Show Gist options
  • Save sebastiancarlos/04b2de48a6f9e9b393c366c83e38778f to your computer and use it in GitHub Desktop.
Save sebastiancarlos/04b2de48a6f9e9b393c366c83e38778f to your computer and use it in GitHub Desktop.
The Python-Combinator (A multi-argument Z-Combinator for Common Lisp)
(defun PY (recursive-logic)
"The 'Python combinator'. A variation of the 'Z combinator' which takes
recursive lambdas with a 'self' recursive argument (hence 'python'),
and any number of arguments.
How does it work? I have no fucking idea. Ask God."
((lambda (x) (funcall x x))
(lambda (x) (lambda (&rest args)
(apply recursive-logic
(lambda (&rest inner-args)
(apply (funcall x x) inner-args))
args)))))
;; (PY (lambda (self) (funcall self))) ; Uncomment to summon Cthulhu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment