(***** session is starting -- Sun Oct 23 12:14:34 IDT 2022 ****) 1+2;; let x = 2+3;; x*x;; let x = y+1;; x;; let y = 7 in y*y;; y;; let y = 7 in print_int(y);; let s = "a\\n" in print_string(s);; 1+3;; 1.0;; 1.5;; 1.0+1.5;; 1.0 +. 1.5;; 1 +.1;; true;; 3<3;; "a string" ^ " " ^ "of characters";; (5,"hey",5.0);; 5,"hey",5.0;; let x=5;; let x=5.5;; x;; x=5;; x;; z;; z=5;; let x =3;; x;; x = 5;; fun x -> x+2;; 5;; fun x -> x+2;; 5;; (fun x -> x+2)3;; (fun x -> x+2) 3;; (fun x -> x+2) (3);; (fun x -> x+2)(3);; fun x -> x+2;; fund (x,y) -> x+2*y;; fun x -> x+2;; fun (x,y) -> x+2*y;; fun x,y -> x+2*y;; fun (x,y) -> x+2*y;; fun(x) -> x+2;; fun x -> x+2;; let f = fun x -> x+2;; f 3;; (f)5;; fun x -> x+2 5;; let f = fun x -> x+2;; f 3;; let f = fun x -> x+2;; let f(x) = x+2;; let h = (fun f -> (fun x -> f(x) + x));; h 5;; let h = (fun f -> (fun x -> f(x) + x));; h (x -> x+1);; h (fun x -> x+1);; let h = (fun f -> (fun x -> f(x) + x));; h (fun x -> x+1);; (h (fun x -> x+1))5;; let o = (fun f -> (fun x -> x + x));; let h = (fun f -> (fun x -> f(x) + x));; let h = fun f x -> f(x)+x;; let f = fun n -> n+1;; let f = fun -> if n = 1 then n else n*f(n-1));; let f = fun n -> if n = 1 then n else n*f(n-1));; let f = fun n -> if n = 1 then n else n*f(n-1);; let f = fun n -> n+1;; f 5;; let f = fun n -> if n = 1 then n else n*f(n-1);; f 5;; let f = fun n -> n+1;; f 5;; let f = fun n -> if n = 1 then n else n*f(n-1);; f 5;; let rec f = fun n -> if n = 1 then n else n*f(n-1);; f 5;; let neg x -> match x with \n true -> false\n | false -> true;; let neg = x -> match x with \n true -> false\n | false -> true;; let neg = fun x -> match x with \n true -> false\n | false -> true;; neg true;; neg false;; let f = fun x -> match x with\n 1 -> 1\n | x -> x*x;; f 1;; f 5;; let f = fun x -> match x with\n 1 -> 1\n | _ -> x*x;; let first = fun (x,y) -> x;; first ("a", 5);; let first = fun (x,y) -> x;; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; f(1);; g(1);; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; f(1,2);; f(1)(2);; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; f(1)(2);; g(1,2);; g(1)(2);; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; let curry = (fun f -> (fun x -> (fun y -> (f (x, y)))));; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; (***** session is starting -- Sun Oct 23 13:40:10 IDT 2022 ****) let curry = (fun f -> (fun x -> (fun y -> (f (x, y)))));; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; let curry = (fun f -> (fun x -> (fun y -> (f (x, y)))));; let g = fun (x,y) -> x+2*y;; let f = fun x -> (fun y -> x+2*y);; (curry g)(1,2);; (curry g)(1)(2);; f(1)(2);; let f = fun x -> (fun y -> x+2*y);; (curry g)(1)(2);; let f = fun x -> (fun y -> x+2*y);; let g = fun (x,y) -> x+2*y;; f(1)(2);; (curry g)(1)(2);; f(5)(6);; (curry g)(5)(6);; let uncurry = (fun f -> (fun (x,y) -> ((f x) y)));; g(1,2);; (uncurry f)(1,2);; if true then 1 elseif true then 1 else 1;; if true then 1 else if true then 1 else 1;; let rec fib = fun n -> match n with \n 0 -> 0 \n |1 -> 1\n | n -> fib(n-1) + fib(n-2);; fib 3;; fib 5;; fib 6;; fib 10;; fib 20;; fib 30;; fib 40;; fib 400;; let rec iter = fun n f x -> if n=0 then x else f (iter (n-1) f x);; let f = fun (x,y) -> (x+y,x);; let fibb n = first(iter n (fun(x,y)->(x+y,x))(1,0));; let first = fun (x,y) -> x;; let rec iter = fun n f x -> if n=0 then x else f (iter (n-1) f x);; let f = fun (x,y) -> (x+y,x);; let fibb n = first(iter n (fun(x,y)->(x+y,x))(1,0));; let fibb n = first(iter n f(1,0));; let fibb n = first(iter n f (1,0));; fibb(400);; fibb(4000);; fibb(40000);; fibb(0);; let fibb n = second(iter n f (1,0));; let second = fun (x,y) -> y;; let fibb n = second(iter n f (1,0));; fibb 0;; fibb 1;; fibb 2;; fibb 3;; fibb 4;; fibb 5;; fibb 6;; iter;; (uncurry iter);; iter;; let rec iter = fun n f x -> if n=0 then x else f (iter (n-1) f x);; let fibb n = second(iter n f (1,0));; let fibb = fun n -> second(iter n f (1,0));; let f = fun (x,y) -> (x+y,y);; let fibb n = first(iter n f (1,0));; let f = fun (x,y) -> (x+y,y);; let fibb n = first(iter n f (1,0));; fibb 0;; let fibb n = first(iter n f (0,1));; fibb 0;; fibb 1;; fibb 2;; fibb 3;; fibb 4;; let fibb n = first(iter n f (0,1));; let f = fun (x,y) -> (x+y,y);;