tweaked arithmetic
[lambda.git] / arithmetic.mdwn
index f7406cc..7812755 100644 (file)
@@ -44,7 +44,20 @@ Here are a bunch of pre-tested operations for the untyped lambda calculus. In so
        let map = \f lst. lst (\h sofar. make_list (f h) sofar) empty  in
        let filter = \f lst. lst (\h sofar. f h (make_list h sofar) sofar) empty  in ; or
        let filter = \f lst. lst (\h. f h (make_list h) I) empty  in
-       
+
+       ; append list2 to list1 with: list1 make_list list2
+       let singleton = \x f z. f x z  in
+       let reverse = \lst. lst (\h sofar. sofar make_list (singleton h)) empty  in
+       let zip = \left right. left (\h sofar. sofar (\x y. isempty y
+                                                                       sofar
+                                                                       (make_pair (make_list () x) (tail y))
+                                                                       )
+                                                                       (make_pair empty (map right (\h u v. u v h)))
+                                                               )
+                                               (\x y. reverse x)  in
+       let all = \f lst. lst (\h sofar. and sofar (f h)) true  in
+       let any = \f lst. lst (\h sofar. or sofar (f h)) false  in
+
 
        ; version 1 lists
 
@@ -198,10 +211,10 @@ Here are a bunch of pre-tested operations for the untyped lambda calculus. In so
                ))  in
 
 
-       ; Curry's fixed point combinator
+       ; Rosenbloom's fixed point combinator
        let Y = \f. (\h. f (h h)) (\h. f (h h)) in
        ; Turing's fixed point combinator
-       let Z = (\u f. f (u u f)) (\u f. f (u u f))  in
+       let Theta = (\u f. f (u u f)) (\u f. f (u u f))  in
 
 
        ; length for version 1 lists
@@ -218,7 +231,7 @@ Here are a bunch of pre-tested operations for the untyped lambda calculus. In so
 
 
 
-       fact Z 3  ; returns 6
+       fact Theta 3  ; returns 6
 
 
 <!--
@@ -239,3 +252,23 @@ Here are a bunch of pre-tested operations for the untyped lambda calculus. In so
                        ; and consume is
                        (\p. p get_2nd p)  in ; or
 -->
+
+<!--
+       gcd
+       pow_mod
+
+
+       show Oleg's definition of integers:
+               church_to_int = \n sign. n
+               church_to_negint = \n sign s z. sign (n s z)
+
+               ; int_to_church
+               abs = \int. int I
+
+               sign_case = \int ifpos ifzero ifneg. int (K ifneg) (K ifpos) ifzero
+
+               negate_int = \int. sign_case int (church_to_negint (abs int)) zero (church_to_int (abs int))
+
+       for more, see http://okmij.org/ftp/Computation/lambda-arithm-neg.scm
+
+-->