From c5fcf7179a83ef65c86c6a4a390029149e518649 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Tue, 5 Oct 2021 21:49:54 +0200 Subject: Duzy commit ze smieciami --- Semestr 3/pf/lista1/zad6.ml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Semestr 3/pf/lista1/zad6.ml (limited to 'Semestr 3/pf/lista1/zad6.ml') diff --git a/Semestr 3/pf/lista1/zad6.ml b/Semestr 3/pf/lista1/zad6.ml deleted file mode 100644 index 46e7f6d..0000000 --- a/Semestr 3/pf/lista1/zad6.ml +++ /dev/null @@ -1,37 +0,0 @@ -type cbool = { cbool : 'a. 'a -> 'a -> 'a } -type cnum = { cnum : 'a. ('a -> 'a) -> 'a -> 'a } - - -let even n = - { cbool = fun tt ff -> fst (n.cnum (fun (a, b) -> (b, a)) (tt, ff))} - - -let ctrue = - { cbool = fun a b -> a} -let cfalse = - { cbool = fun a b -> b} -let cand f1 f2 a b = f1.cbool (f2.cbool a b) b -let cor f1 f2 a b = f1.cbool a (f2.cbool a b) -let cbool_of_bool b = if b then ctrue else cfalse -let bool_of_cbool f = f.cbool true false - -let zero = { cnum = fun f x -> x } -let succ fn = { cnum = fun f x -> fn.cnum f (f x) } -let add f1 f2 = { cnum = fun f x -> f1.cnum f (f2.cnum f x) } -let mul f1 f2 = { cnum = fun f x -> f1.cnum (f2.cnum f) x } -(* let is_zero f = *) -let rec cnum_of_int = function - | 0 -> zero - | n -> succ (cnum_of_int (n - 1)) -let is_zero f = - let g x = x + 1 - in if (f.cnum g 0) = 0 then ctrue else cfalse -let int_of_cnum f = f.cnum (fun x -> x + 1) 0 - -let one = succ zero -let two = succ one -let three = succ two -let four = succ three -let five = succ four - -let func x = x * 2 \ No newline at end of file -- cgit v1.2.3