X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=lambda_library.mdwn;h=2e65f5ccea0e224fdeb262b6dcc2ad10fd9700c8;hp=5623b9fa219b4cf9ef0fca41b8fe098768b803df;hb=7369cbe617f9b283dc9a585858dd1085ff7266f8;hpb=2c604a7f018e6e2af314f39a07dce0a15f1d9cb8 diff --git a/lambda_library.mdwn b/lambda_library.mdwn index 5623b9fa..2e65f5cc 100644 --- a/lambda_library.mdwn +++ b/lambda_library.mdwn @@ -236,6 +236,12 @@ and all sorts of other places. Others of them are our own handiwork. let Theta = (\u f. f (u u f)) (\u f. f (u u f)) in + ; now you can search for primes, do encryption :-) + let gcd = Y (\gcd m n. iszero n m (gcd n (mod m n))) in ; or + let gcd = \m n. iszero m n (Y (\gcd m n. iszero n m (lt n m (gcd (sub m n) n) (gcd m (sub n m)))) m n) in + let lcm = \m n. or (iszero m) (iszero n) 0 (mul (div m (gcd m n)) n) in + + ; length for version 1 lists let length = Y (\self lst. isempty lst 0 (succ (self (tail lst)))) in @@ -314,7 +320,7 @@ let list_equal = ; (might_for_all_i_know_still_be_equal?, tail_of_reversed_right) ; when left is empty, the lists are equal if right is empty (make_pair - (not (isempty right)) + true ; for all we know so far, they might still be equal (reverse right) ) ; when fold is finished, check sofar-pair