RosettaCodeData/Task/Y-combinator/TXR/y-combinator-1.txr
2016-12-05 22:15:40 +01:00

13 lines
230 B
Text

;; The Y combinator:
(defun y (f)
[(op @1 @1)
(op f (op [@@1 @@1]))])
;; The Y-combinator-based factorial:
(defun fac (f)
(do if (zerop @1)
1
(* @1 [f (- @1 1)])))
;; Test:
(format t "~s\n" [[y fac] 4])