text
stringlengths
0
601k
let string_implode (l : char list) : string = String.concat "" (List.map (String.make 1) l);;
let evens (max : int) : int list = unfold (fun x -> (x, x+2)) (fun x -> max <= x) 0;;
let fib (max : int) : int list = unfold (fun (a,b) -> (a,(b, a+b))) (fun (a,b) -> (max,b) <= (a,b)) (1,1);;
let zip (l1 : 'a list) (l2 : 'b list) : ('a * 'b) list = let f (l1,l2)= ((List.hd l1, List.hd l2), (List.tl l1, List.tl l2)) in unfold f (fun (l1,l2) -> ((List.length l1 = 0) || (List.length l2 = 0))) (l1,l2) let rec allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (func...
let string_explode (s : string) : char list = tabulate (function x -> (String.get s x)) (String.length s);;
let string_implode (l : char list) : string = let stringified_list = List.map Char.escaped l in List.fold_left (^) "" stringified_list;;
let evens (max : int) : int list = unfold (fun n -> (n, n+2)) (fun b -> max <= b) 0;;
let fib (max : int) : int list = unfold (fun (a, b) -> (a, (b, a+b))) (fun (a,b) -> max <= a) (1,1);;
let pascal (max : int) : int list list = unfold ( fun (l1, l2) -> let list = 0 :: l2 in (l1, (l2, (List.map2 (+) list (List.rev list)))) ) (fun (l1,l2) -> max < ((List.length l1))) ([1;],[1; 1]);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter ( fun cupcake -> let Cupcake (_, _, _, ingredients) = cupcake in not (List.exists ( fun ingredient -> not (List.for_all ( fun allergen -> ingredient != allergen ) allergens) ) ingredients) ) cupcakes;;
let string_explode (s : string) : char list = let extract_char (i : int) = String.get s i in tabulate extract_char (String.length s);;
let string_implode (l : char list) : string = let convert_str (i : int) = Char.escaped (List.nth l i) in String.concat "" (tabulate convert_str (List.length l)) ;;
let evens (max : int) : int list = unfold (fun n -> (2 * n, n + 1)) (fun n -> (n * 2 >= max)) 0 ;;
let fib (max : int) : int list = let fib_calc (x, y) = (x + y, (x + y, x)) in unfold fib_calc (fun (x, y) -> (x + y >= max)) (0, 1) ;;
let pascal (max : int) : int list list = let pascal_value_gen ((index : int), (row : int), (tri : int list list)) = if (index == row) then (1, (0, row + 1, tri)) else if (index == 0) then (1, (index + 1, row, tri)) else let prev_line = List.nth tri (row - 1) in let prev_1 = List.nth prev_line (index - 1) in let prev_2 ...
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_containing (allergen : ingredient) (c : cupcake) = let Cupcake (x, y, z, ls) = c in (List.exists (fun i -> i == allergen) ls) == false in let check_allergen_free (cp : cupcake) = List.for_all (fun a -> not_containing a cp)...
let string_explode (s : string) : char list = let extract_char (i : int) = String.get s i in tabulate extract_char (String.length s);;
let string_implode (l : char list) : string = let convert_str (i : int) = Char.escaped (List.nth l i) in String.concat "" (tabulate convert_str (List.length l)) ;;
let evens (max : int) : int list = unfold (fun n -> (2 * n, n + 1)) (fun n -> (n * 2 >= max)) 0 ;;
let fib (max : int) : int list = let fib_calc (x, y) = (x + y, (x + y, x)) in unfold fib_calc (fun (x, y) -> (x + y >= max)) (0, 1) ;;
let pascal (max : int) : int list list = let pascal_value_gen ((index : int), (row : int), (prev_line : int list)) = if (index == row) then (1, (0, row + 1, prev_line)) else if (index == 0) then (1, (index + 1, row, prev_line)) else let prev_1 = List.nth prev_line (index - 1) in let prev_2 = List.nth prev_line index in...
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_containing (allergen : ingredient) (c : cupcake) = let Cupcake (x, y, z, ls) = c in (List.exists (fun i -> i == allergen) ls) == false in let check_allergen_free (cp : cupcake) = List.for_all (fun a -> not_containing a cp)...
let string_explode (s : string) : char list = tabulate (fun x -> String.get s x) (String.length s);;
let string_implode (l : char list) : string = String.concat ("") (List.map (fun x -> Char.escaped (x)) (l));;
let evens (max : int) : int list = List.filter (fun x -> x mod 2 = 0) (unfold (fun b -> (b, b+1)) (fun b -> max <= b) 0);;
let fib (max : int) : int list = unfold ( fun (a,b) -> ( a, (b, a+b) ) ) ( fun (a,b) -> max <= a ) (1,1);;
let pascal (max : int) : int list list = unfold (fun b -> (b, List.map2 (+) ([0] @ b) (b @ [0]) )) (fun b -> max+1 <= List.length (b)) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_,_,_, ingredient_list)) -> List.for_all (fun _ -> not (List.exists (fun z -> (List.mem z allergens)) ingredient_list)) allergens) (cupcakes);;
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = String.concat ("") (List.map (Char.escaped ) (l));;
let evens (max : int) : int list = List.filter (fun x -> x mod 2 = 0) (unfold (fun b -> (b, b+1)) ((<=) max) 0);;
let fib (max : int) : int list = unfold ( fun (a,b) -> ( a, (b, a+b) ) ) ( fun (a,b) -> max <= a ) (1,1);;
let pascal (max : int) : int list list = unfold (fun b -> (b, List.map2 (+) (0 :: b) (b @ [0]) )) (fun b -> max+1 <= List.length (b)) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_,_,_, ingredient_list)) -> List.for_all (fun _ -> not (List.exists (fun z -> (List.mem z allergens)) ingredient_list)) allergens) (cupcakes);;
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s) ;;
let string_implode (l : char list) : string = let string_list = List.map Char.escaped l in String.concat "" string_list;;
let evens (max : int) : int list = unfold (fun b -> (b, b+2)) ((<=) max) 0 ;;
let fib (max : int) : int list = let fib_aux (b: 'a list) = List.append [(List.nth b 1)] [(List.nth b 0 + List.nth b 1)] in unfold (fun b -> (List.nth b 0, fib_aux b)) (fun b -> max <= List.nth b 0) [1;1] ;;
let pascal (max : int) : int list list = let make_row l = let row1 = List.append [0] l in let row2 = List.append l [0] in List.map2 (+) row1 row2 in unfold (fun b -> (b, make_row b)) (fun b -> max <= (List.length b) - 1) [1] ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let return_cupcakes_with_no_allergen (cupcake: cupcake): bool = let Cupcake(_,_,_,ingredients) = cupcake in let is_allergen_free (ingredient: ingredient): bool = not (List.exists (fun b -> b == ingredient) allergens) in List.for_a...
let string_explode (s : string) : char list = List.map (String.get s) (tabulate (function x -> x) (String.length s)) ;;
let string_implode (l : char list) : string = String.concat "" (List.map (Char.escaped) l) ;;
let evens (max : int) : int list = if max < 0 then domain() else unfold (fun x -> (x, x+2)) ( (<=) max ) 0 ;; let myf = fun b -> ((List.nth b 0)+(List.nth b 1),(List.nth b 1)::(List.nth b 0)+(List.nth b 1)::[]);;
let fib (max : int) : int list = if max < 0 then domain() else if max = 1 || max = 0 then [] else [1;1] @ unfold myf (fun x -> max <= (List.nth x 0) + (List.nth x 1)) [1;1] ;; let one_row (lst: int list) = let next_element = fun b -> ((List.nth b 0)+(List.nth b 1),(List.tl b)) in let middle_lst = unfold next_element (f...
let pascal (max : int) : int list list = if max < 0 then domain() else match max with |0 -> [] |1 -> [[1]] |2 -> [[1];[1;1]] |_ -> [[1];[1;1]] @ unfold f2 (fun x -> (List.length x) >= max) [[1];[1;1]] ;; let f3 b = let (l1,l2) = b in ( ((List.hd l1),(List.hd l2)), (List.tl l1,List.tl l2) ) ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = if allergens=[] then cupcakes else let filter = fun cake -> match cake with |Cupcake (_,_,_,[])-> true |Cupcake (_,_,_,ingredients)-> let exist = fun allergen -> not ( List.exists ( (==) allergen ) ingredients) in List.for_all exi...
let string_explode (s : string) : char list = let indexes = tabulate (fun x -> x) (String.length s) in List.map (String.get s) indexes;;
let string_implode (l : char list) : string = let func s c = s^(Char.escaped c) in List.fold_left func "" l;;
let evens (max : int) : int list = unfold (fun b -> (b, b+2)) ((<=) max) 0;;
let fib (max : int) : int list = unfold ( fun b -> if b = (0,0) then (1,(0,1)) else (((fst b) + (snd b)),((snd b),((fst b) + (snd b)))) ) (fun b -> max <= ((fst b) + (snd b)) || max = 1) (0,0);;
let pascal (max : int) : int list list = unfold ( fun b -> if (List.length b = 0) then ([1],[1]) else if (List.length b =1) then ([1;1],[1;1]) else let temp_list = List.rev b in let temp_list1 = List.tl temp_list in let l1 = List.rev temp_list1 in let l2 = List.tl b in ([1]@(List.map2 (+) l1 l2)@[1], [1]@(List.map2 (+)...
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake(_,_,_,a)) -> (List.for_all (fun b -> (not(List.exists ((=) b) allergens)))) a ) cupcakes;;
let string_explode (s : string) : char list = List.map (String.get s) (tabulate (fun x -> x) (String.length s));;
let string_implode (l : char list) : string = List.fold_left ( ^ ) "" (List.map (Char.escaped) l);;
let evens (max : int) : int list = unfold (fun x -> x, x+2) (fun x -> x >= max) (0);;
let fib (max : int) : int list = unfold (fun(x_1,x_2) -> (x_1+x_2 , (x_1+x_2, x_1))) (fun(x_1,x_2) -> x_1+x_2 >= max) ( 0 , 1 );;
let pascal (max : int) : int list list = unfold (fun(x) -> x, (List.map2 (+) (0 :: x) (List.rev (0:: (List.rev x))))) (fun x -> (List.length x) > max) ([1]);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake(_,_,_,engs) -> (List.for_all(fun eng-> not (List.exists(fun x-> x = eng) allergens)) engs)) cupcakes;;
let string_explode (s : string) : char list = let l = String.length s in tabulate (String.get s) l ;; let s = "asdfg" ;; string_explode s ;;
let string_implode (l : char list) : string = let sl = List.map (Char.escaped) l in List.fold_left (^) "" sl ;; let l = ['a';'s';'d';'f';'g'] ;; string_implode l ;;
let evens (max : int) : int list = unfold (fun b -> (b, b+2)) ( (<=) max) 0 ;; evens 28 ;;
let fib (max : int) : int list = unfold (fun (a, b) -> (a, (b, (a + b)))) (fun (a, b) -> max <= a) (1, 1) ;; fib 21 ;;
let pascal (max : int) : int list list = let generate_seed l = let list1 = List.tl l in let list2 = List.rev (List.tl (List.rev l)) in (l, (List.append (1 :: List.map2 (+) list1 list2) [1])) in unfold (generate_seed) (fun l -> max < List.length l) [1] ;; pascal 7 ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let helper list ing = not (List.exists (fun a -> (a = ing)) list) in let check allers cake = match cake with |Cupcake (_, _, _, l) -> List.for_all (helper allers) l |_ -> false in List.filter (check allergens) cupcakes ;; allergy_...
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = List.fold_left (^) "" (List.map Char.escaped l);;
let evens (max : int) : int list = unfold (fun x -> (x, x+2)) ((<=) max) 0;;
let fib (max : int) : int list = unfold (fun (x,y) -> (y, (y,x+y))) (fun (x,y) -> max <= y) (0,1);;
let pascal (max : int) : int list list = match max with | 0 -> [] | _ -> [1] :: unfold (fun x -> (List.map2 (+) (0::x) (List.append x [0]), List.map2 (+) (0::x) (List.append x [0]))) (fun x -> List.length x = max) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake(p,w,c,l)) -> List.for_all (fun i -> not(List.exists ((=) i) allergens)) l) cupcakes;;
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = List.fold_left (^) "" (List.map Char.escaped l);;
let evens (max : int) : int list = unfold (fun b -> (b, b + 2)) ((<=) max) 0;;
let fib (max : int) : int list = unfold (fun (a, b) -> (a + b, (b, a + b))) (fun (a, b) -> (a + b >= max)) (1, 0);;
let pascal (max : int) : int list list = unfold (fun (l, b) -> (l, (List.map2 (+) (0::l) (List.rev (0::List.rev l)), b + 1))) (fun (l, b) -> List.length l - 1 >= max) ([1], 0);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake(a,b,c,d) -> List.for_all (fun a -> not(List.exists ((=)a) allergens)) d) cupcakes;;
let string_explode (s : string) : char list = let f = String.get s in tabulate f (String.length s);;
let string_implode (l : char list) : string = let fy x y = x^(Char.escaped y) in List.fold_left fy "" l;;
let evens (max : int) : int list = unfold (fun b-> (b,b+2)) ((<=) max) 0;;
let fib (max : int) : int list = unfold (fun b-> if (snd b) = 0 then (1,(0,1)) else (((fst b) + (snd b)),(snd b, (fst b+snd b))) ) (fun b-> (max <= (fst b + snd b)) || (max = 1)) (0,0);;
let pascal (max : int) : int list list = unfold (fun b-> if (List.length b) = 1 then ([1;1],[1;1]) else if (List.length b)=0 then ([1],[1]) else ([1]@(List.map2 (+) (List.tl b) (List.rev (List.tl b)))@[1],[1]@(List.map2 (+) (List.tl b) (List.rev (List.tl b)))@[1]) ) (fun b-> max <=(List.length b)) [];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_,_,_,listOfIngs)) -> List.for_all (fun oneIng -> (not (List.exists (fun a-> (a=oneIng)) (allergens))) ) (listOfIngs)) (cupcakes) ;;
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = (String.concat) ("") (List.map Char.escaped l);;
let evens (max : int) : int list = unfold (fun b -> (b, b+2)) (fun b -> max <= b) 0;;
let fib (max : int) : int list = unfold (fun (fn1,fn2) -> (fn1, (fn2,fn1+fn2))) (fun (fn1,fn2) -> max<=fn1) (1,1);;
let pascal (max : int) : int list list = let f = (fun(l1) -> (l1,List.rev(1::List.rev(1::List.map2 (+) (List.tl l1) (List.rev (List.tl (List.rev l1))))) )) in unfold (f) (fun (l1) -> (List.length l1)>max) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (cupcake) -> (let Cupcake(a,b,c,i) = cupcake in List.for_all (fun (allergen) -> (not(List.exists (fun (ingredient) -> (allergen==ingredient)) i))) allergens)) cupcakes;;
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = List.fold_right (^) (List.map Char.escaped l) "";;
let evens (max : int) : int list = unfold (fun b-> (b, b+ 2)) ((<=) max) 0;;
let fib (max : int) : int list = if max<= 1 then [] else 1::1::unfold (fun (x1, x2)-> ((x1+ x2), (x2, x1+ x2))) (fun (x1, x2)-> max<= (x1+ x2)) (1, 1);;
let pascal (max : int) : int list list = if max< 0 then [[]] else unfold (fun b-> (b ,(List.map2 (+) (0::b) (b @ 0::[])))) (fun b-> max < (List.length b)) (1::[]);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_, _, _, ingres) )-> (List.for_all (fun a' -> not(List.exists ( (=) a') allergens)) ingres)) cupcakes;;
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = List.fold_right (^) (List.map Char.escaped l) "";;
let evens (max : int) : int list = unfold (fun b-> (b, b+ 2)) ((<=) max) 0;;
let fib (max : int) : int list = if max<= 1 then [] else 1::1::unfold (fun (x1, x2)-> ((x1+ x2), (x2, x1+ x2))) (fun (x1, x2)-> max<= (x1+ x2)) (1, 1);;
let pascal (max : int) : int list list = if max< 0 then [[]] else unfold (fun b-> (b ,(List.map2 (+) (0::b) (b @ 0::[])))) (fun b-> max < (List.length b)) (1::[]);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_, _, _, ingres) )-> (List.for_all (fun a' -> not(List.exists ( (=) a') allergens)) ingres)) cupcakes;;