Skip to content

Fruit Standard Library

Kamil Adam edited this page Aug 22, 2023 · 4 revisions

Arithmetic

~0 \f \x x
~succ \n \f \x n f x
#~plus \m \ n \f \x m f (n f x)
~plus \m \n m succ n
#~mult \m \n \f m (n f)
~mult \m \n m (plus n) 0
~pow \b \e e b
#~pred \n \f \x n (\g \h h (g f)) (\u x) (\u u)
~pred \n first (n fi (pair 0 0)).
#~pred \n n (\g \k ISZERO (g 1) k (PLUS (g k) 1)) (\v 0) 0
~sub \m \n n pred m

Logic

~true \x \y x
~false \x \y y

~not \x x false true
~and \x \y x y false
~or \x \y x true y

~if \p \a \b p a b
~iszero \n n (\x false) true
~leq \m \n iszero (sub m n)

Structures

~pair \x \y \f f x y
~first \p p true
~second \p p false
~nil \x true
~null \p p (\x \y false)
~fi \x pair (second x) (succ (second x))

Recursion

~fix \g (\x g (x x)) (\x g (x x))

Combinators

~I \x x
~S \x \y \z x z (y z)
~K \x \y x
~B \x \y \z x (y z)
~C \x \y \z x z y
~W \x \y x y y
~omega \x x x
~omega2 omega omega
Clone this wiki locally