Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Y Combinator in TXR's embedded Lisp dialect:

    @(do
      ;; 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: 4! -> 24
      (pprinl [[y fac] 4]))


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: