From 8b95e631498db147fc68fd97b156608f11291000 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Thu, 30 Sep 2010 14:47:15 -0400 Subject: [PATCH] tweaked arithmetic Signed-off-by: Jim Pryor --- arithmetic.mdwn | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arithmetic.mdwn b/arithmetic.mdwn index bc15ae8d..7812755d 100644 --- a/arithmetic.mdwn +++ b/arithmetic.mdwn @@ -44,8 +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 - let reverse = \lst. lst (\h t. t make_list (\f n. f h n)) 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 -- 2.11.0