(***** session is starting -- Sun Nov 3 14:20:39 IST 2024 ****) print_string("hey"\\n);; print_string("hey\\n");; 1+2;; dfgsasdfsga\ndsgasd\nfas;; (***** session is starting -- Sun Nov 3 14:24:03 IST 2024 ****) 1+2;; let x = 2+3;; x*x;; let x = y + 1;; let x = x + 1;; x = x+1;; let y = 7 in y*y;; y;; 1;; 1+3;; 2*2;; 1;; 1.0;; 1.5;; 1.5 + 2.5;; 1.5 +. 2.5;; 5.5 +. 1.0;; true;; true && true;; true || true;; not true;; let x = 3 in if x < 0 then x else x*x;; " a string";; "a string" ^ " of characters";; (5, "hey", 5.0);; 5;; 5, "hey", 5.0;; fun x -> x + 2;; 5;; fun (x,y) -> x+2*y;; (fun (x,y) -> x + 2*y)((1,1));; let f = (fun x -> x + 1);; f(3);; f 3;; let h = (fun f -> (fun x -> f(x) + x));; (h (fun x -> x+1))(5);; fun x -> fun y -> x+y;; (fun x -> fun y -> x+y)(3)(4);; let f = (fun x -> fun y -> x+y);; f 3 4;; let f = (fun n -> n+1);; f(5);; let f = (fun n -> n+1);; let f = (fun n -> if n = 1 then n else n* f(n-1));; f(5);; let f = (fun n -> n+1);; let f = (fun n -> if n = 1 then n else n* f(n-1));; let g = (fun n -> if n = 1 then n else n* g(n-1));; let rec f = (fun n -> if n = 1 then n else n* f(n-1));; f 5;; let neg = fun x -> match x with \n | true -> false\n | false -> true;; neg true;; let rec f = fun x -> match x with | 1 -> 1 | x -> x*f(x-1);; f 5;; let f = fun x -> match x with | 1 -> 1 | x -> 0;; f 1;; f 5;; let f = fun x -> match x with | 1 -> 1 | -> 0;; let f = fun x -> match x with | 1 -> 1 | _ -> 0;; let first = fun (x,y) -> x;; let first = fun (x,y) -> x+y;; let first = fun (x,y) -> x;; let first = fun (x,y) -> x+y;; let first = fun (x,y) -> x;; let first = fun (x,y) -> x+y;; let first = fun (x,y) -> x;; fun (f,g) -> (fun x -> (f(g(x))));; fun (f,g) -> (fun x -> (g(f(x))));; (fun (f,g) -> (fun x -> (g(f(x)))))(((fun x->x),(fun x ->x)));; let f = (fun x -> fun y -> x+y);; f(3);; (f(3))(2);; ((fun (f,g) -> (fun x -> (g(f(x)))))(((fun x->x),(fun x ->x))))5;; (***** session is starting -- Sun Nov 3 15:33:13 IST 2024 ****) (***** session is starting -- Sun Nov 3 15:46:45 IST 2024 ****) let f = fun x -> (fun y -> x + 2*y);; let g = fun (x,y) -> x + 2*y;; f(1);; g(1);; f(1,2);; g(1,2);; f(1)(2);; g(1)(2);; let curry = fun g -> (fun x -> (fun y -> g(x,y)));; g;; let g = fun (x,y) -> x + 2*y;; curry g;; f(1)(2);; g(1)(2);; f(1)(2);; (curry g)(1)(2);; let uncurry = fun f -> (fun (x,y) -> ((f x)y));;