Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
Created March 19, 2025 05:40
Show Gist options
  • Save sebastiancarlos/b059c33315302d9f770c849039a268f3 to your computer and use it in GitHub Desktop.
Save sebastiancarlos/b059c33315302d9f770c849039a268f3 to your computer and use it in GitHub Desktop.
Examples for the Python-Combinator (A multi-argument Z-Combinator for Common Lisp)
(let ((factorial (PY (lambda (self n)
(if (<= n 1)
1
(* n (funcall self (- n 1)))))))
(fibonacci (PY (lambda (self n)
(if (<= n 1)
n
(+ (funcall self (- n 1))
(funcall self (- n 2)))))))
(ayy-lmao (PY (lambda (self ayy lmao)
(if (equal ayy "lmao")
"ayy lmao"
(funcall self lmao ayy))))))
(list (funcall factorial 5)
(funcall fibonacci 10)
(funcall ayy-lmao "ayy" "lmao"))) ; => (120 55 "ayy lmao")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment