Lambda Calculus in Janet 1 ▲ Alex Alejandre's Recent Posts 171 days ago · 8 min read1589 words · Tech · hide · Fediverse post To some extent, Lisp just extends and thus includes lambda calculus. Indeed, short functions already permit: |(+ $ 1) # λx.x+1 (|(+ $ 1) 3) # (λx.x+1) 3 (|(+ $ 1) (|(+ $ 2) 3)) # (λx.x+1) ((λy.y+2) 3) Going a bit further, a simple macro gives us more or less everything: (defmacro λ `Executable lambda calc: ((λ x . + 5 x) 5)` [v dot & args] (if (= 1 (length args)) ~(fn [,v] ,(first args)) # to handle e.g. identity: ((λ x . x) 5) ~(fn [,v] (,;args)))) ((λ x . + 1 x) 3) # (λx.x+1) 3 ((λ x . + x 1) ((λ y . + y 2) 3)) # (λx.x+1) ((λy.y+2) 3) # n.b. these versions are the same: (def K (λ x . (λ y . x))) (def K (λ x . λ y . x)) On the basis of this macro, you can implement anything you want: (def TRUE (λ x . λ y . x)) (def FALSE (λ x . λ y . y)) (def IF (λ p . λ a . λ b . (p a) b)) # evaluates both branches (def AND (λ p . λ q . (p q) p)) (def OR (λ p . λ q . (p p) q)) (def NOT (λ p . λ a . λ b . (p b) a)) (def ZERO (λ f . λ x . x)) (def SUCC (λ n . λ f . λ x . f ((n f) x))) (def ONE (SUCC… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town