text
stringlengths
0
601k
let string_implode (l : char list) : string = let l_new = List.map (Char.escaped) (l) in List.fold_left (^) "" l_new;;
let evens (max : int) : int list = let raise2 (x : int) : ('a * 'seed) = (x, x+2) in let stop (y : int) : bool = not (y < max) in unfold raise2 stop 0;;
let fib (max : int) : int list = let next_fib ((a,b) : int*int) : ('a * 'seed) = (a+b, (b,a+b)) in let stop ((a,b): int*int) : bool = (a+b) >= max in unfold next_fib stop (1,0);;
let pascal (max : int) : int list list = let next_row (one : int list) : ('a * 'seed) = if List.length one = 0 then ([1],[1]) else (List.map2 (+) ([0]@one) (one@[0]), List.map2 (+) ([0]@one) (one@[0])) in let stop (one : int list) : bool = not ((List.length one) < max) in unfold next_row stop [];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let cup_to_ingred (Cupcake(price, weight, calories, ingredients) : cupcake) : ingredient list = ingredients in let sans_allergen (ingred : ingredient) : bool = not (List.exists (fun check -> List.mem check allergens) [ingred]) in ...
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);;
let string_implode (l : char list) : string = List.map Char.escaped l |> List.fold_left (^) "";;
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) -> max <= a+b) (1, 0);;
let pascal (max : int) : int list list = let next_row l = (List.map2 (+) (List.tl l) (List.rev l |> List.tl |> List.rev)) @ [1] |> (@) [1] in unfold (fun a -> (a, next_row a)) (fun a -> max < List.length a) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let cfilter (Cupcake (_, _, _, l)) = List.for_all (fun a -> not (List.exists ((=) a) l)) allergens in List.filter cfilter cupcakes;;
let string_explode (s : string) : char list = let getChar = String.get s in tabulate getChar ((String.length s)) ;;
let string_implode (l : char list) : string = let new_list = List.map (String.make 1) l in String.concat "" new_list ;;
let evens (max : int) : int list = unfold (fun a -> (a, a+2)) ((<=) 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 = let pascalList l = let list1 = 0 :: l in let list2 = List.rev list1 in List.map2 (+) list1 list2 in unfold (fun a -> (a, pascalList a)) (fun a -> max <= (List.length a)-1) [1] ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) = let notContainsAllergen l = not (List.exists ((=) l) allergens) in let allNotContainsAllergen = List.for_all notContainsAllergen in List.filter (fun (Cupcake(a,b,c,ingre)) -> (allNotContainsAllergen ingre)) 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 = if (max mod 2 = 0) then unfold (fun b -> (b,b+2)) ((=) max) (0) else unfold (fun b -> (b,b+2)) (fun b -> max = b - 1) (0) ;;
let fib (max : int) : int list = unfold (fun (x,y) -> (x, (y,x+y))) (fun (x,y) -> max <= x) (1,1) ;;
let pascal (max : int) : int list list = 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 = if cupcakes = [] then [] else if allergens = [] then cupcakes else List.filter ( function Cupcake (_,_,_,x) -> List.for_all (fun i -> not (List.exists (fun z -> z = i) allergens)) x) (cupcakes) ;;
let string_explode (s : string) : char list = tabulate (String.get s) ((String.length s));;
let string_implode (l : char list) : string = let convert = List.map (Char.escaped) in String.concat ("") (convert 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 (l,r) -> (r,(r,l+r)) ) (fun (l,r) -> r>= max) (0,1);;
let pascal (max : int) : int list list = unfold (fun (counter,cur_row) -> (cur_row,(counter+1,List.map2 (+) (0 :: cur_row) (cur_row @ [0])))) (fun (counter,cur_row) -> counter>= max) (0,[1]);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_have(aller : ingredient) (cp: cupcake) = let Cupcake(a,b,c,ds) = cp in (List.exists (fun a -> a == aller) ds) == false in List.filter (fun cup -> List.for_all (fun a -> nothave a cup) allergens) cupcakes;;
let string_explode (s : string) : char list = tabulate (String.get s) ((String.length s));;
let string_implode (l : char list) : string = let convert = List.map (Char.escaped) in String.concat ("") (convert 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 (l,r) -> (r,(r,l+r)) ) (fun (l,r) -> r>= max) (0,1);;
let pascal (max : int) : int list list = unfold (fun (counter,cur_row) -> (cur_row,(counter+1,List.map2 (+) (0 :: cur_row) (cur_row @ [0])))) (fun (counter,cur_row) -> counter>= max) (0,[1]);;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_have(aller : ingredient) (cp: cupcake) = let Cupcake(a,b,c,ds) = cp in (List.exists (fun a -> a == aller) ds) == false in List.filter (fun cup -> List.for_all (fun a -> not_have a cup) 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)) (fun b -> max <= b) 0;;
let fib (max : int) : int list = unfold (fun (n1, n2) -> n1, (n2, n1 + n2)) (fun (x, _) -> x >= max) (1,1);;
let pascal (max : int) : int list list = unfold (fun b -> (b, List.map2 (+) ([0]@b) (b@[0]))) (fun b-> List.length b > max) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_,_,_, ing)) -> List.for_all (fun ing -> not (List.exists (fun allerg -> allerg = ing ) allergens)) ing) 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)) (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 (+) (b@[0]) (0::b)))) (fun b -> max < List.length b) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake (_, _, _, ingredients) -> List.for_all (fun ingredient -> not(List.exists (fun allergen -> allergen = ingredient) allergens )) ingredients ) 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 (fun a -> (^) (Char.escaped (a))) l "";;
let evens (max : int) : int list = unfold (fun b->(b,b+2)) ((<=) max) 0;;
let fib (max : int) : int list = if max=0 || max=1 then [] else 1::(unfold (fun x -> (x,int_of_float(float_of_int(x)*.(1.+.sqrt 5.0)/.2.+.0.5))) (fun b -> max <= b) 1);;
let pascal (max : int) : int list list = let f = fun(x) -> (x, List.map2 (+) (List.rev ((0::(List.rev x)))) (0::x) ) in unfold f (fun x -> max < (List.length x)) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_allergic b = not (let check x = (x = b) in List.exists check allergens) in List.filter (function Cupcake(_,_,_,ingredient) -> List.for_all not_allergic ingredient) 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 (fun a -> (^) (Char.escaped (a))) l "";;
let evens (max : int) : int list = unfold (fun b->(b,b+2)) ((<=) max) 0;;
let fib (max : int) : int list = if max=0 || max=1 then [] else 1::(unfold (fun x -> (x,int_of_float(float_of_int(x)*.(1.+.sqrt 5.0)/.2.+.0.5))) (fun b -> max <= b) 1);;
let pascal (max : int) : int list list = let f = fun(x) -> (x, List.map2 (+) (List.rev ((0::(List.rev x)))) (0::x) ) in unfold f (fun x -> max < (List.length x)) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_allergic b = not (let check x = (x = b) in List.exists check allergens) in List.filter (function Cupcake(_,_,_,ingredient) -> List.for_all not_allergic ingredient) 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 (fun a -> (^) (Char.escaped (a))) l "";;
let evens (max : int) : int list = unfold (fun b->(b,b+2)) ((<=) max) 0;;
let fib (max : int) : int list = if max=0 || max=1 then [] else 1::(unfold (fun x -> (x,int_of_float(float_of_int(x)*.(1.+.sqrt 5.0)/.2.+.0.5))) (fun b -> max <= b) 1);;
let pascal (max : int) : int list list = let f = fun(x) -> (x, List.map2 (+) (List.rev ((0::(List.rev x)))) (0::x) ) in unfold f (fun x -> max < (List.length x)) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let not_allergic b = not (let check x = (x = b) in List.exists check allergens) in List.filter (function Cupcake(_,_,_,ingredient) -> List.for_all not_allergic ingredient) 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 b -> (b, b + 2)) (fun b -> b >= max) 0;;
let fib (max : int) : int list = unfold (fun (a, b) -> (a + b), (b, (a+b))) (fun (a,b) -> max <= (a+b)) (1, 0);;
let pascal (max : int) : int list list = if max = 0 then [] else [1] :: unfold (fun a -> List.map2 (+) (0 :: a) (List.rev(0 :: a)), List.map2 (+) (0 :: a) (List.rev(0 :: a))) (fun a -> List.length a = max) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = if cupcakes = [] then [] else List.filter (function Cupcake (_,_,_, ingredients) -> List.for_all (fun i -> not ( List.exists (fun a -> a = i) allergens))ingredients) 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 x -> (x, x+2)) ((<=) max) 0 ;;
let fib (max : int) : int list = unfold (fun (x, y) -> (x, (y, x + y))) (fun (x,y) -> max <= x) (1, 1) ;;
let pascal (max : int) : int list list = let next_row (row: int list) = List.map2 (+) (0 :: row)(row @ [0]) in unfold (fun x -> (x, next_row x)) (fun x -> max <= (List.length x) - 1) [1] ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake (_, _, _, ingredients) -> List.for_all (fun ingredient -> (not (List.exists (fun x -> x = ingredient) allergens))) ingredients) 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 x -> (x, x+2)) ((<=) max) 0 ;;
let fib (max : int) : int list = unfold (fun (x, y) -> (x, (y, x + y))) (fun (x,y) -> max <= x) (1, 1) ;;
let pascal (max : int) : int list list = let next_row (row: int list) = List.map2 (+) (0 :: row)(row @ [0]) in unfold (fun x -> (x, next_row x)) (fun x -> max <= (List.length x) - 1) [1] ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake (_, _, _, ingredients) -> List.for_all (fun ingredient -> (not (List.exists (fun x -> x = ingredient) allergens))) ingredients) cupcakes ;;
let string_explode (s : string) : char list = let n = String.length s in let getIndex (i: int) : char = String.get s i in tabulate getIndex n ;;
let string_implode (l : char list) : string = let strList = List.map Char.escaped l in String.concat "" strList ;;
let evens (max : int) : int list = unfold (fun b -> (b, b+2)) ((<=) max) 0 ;;
let fib (max : int) : int list = unfold (fun (a, b) -> (b, (b, a + b))) (fun (a, b) -> max <= b) (0, 1) ;; let rec computeRow (rowPrev: int list) (i: int) (acc: int list): int list = if i <= 0 then 1 :: acc else let ele = List.nth rowPrev (i-1) + List.nth rowPrev i in computeRow rowPrev (i-1) (ele::acc) ;;
let pas (l: int list list) = let rowPrev = List.nth l (List.length l - 1) in let i = List.length rowPrev - 1 in let nextRow = computeRow rowPrev i [1] in (nextRow, l @ [nextRow]) ;;
let pascal (max : int) : int list list = if max = 0 then [] else let stop (lst: int list list) = max <= List.length (List.hd (List.rev lst)) in [1] :: (unfold pas stop [[1]]) ;;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let filter (c: cupcake) : bool = let Cupcake (_, _, _, ingredients) = c in let checkEach (ing: ingredient) : bool = not (List.exists ((=) ing) allergens) in List.for_all checkEach ingredients in List.filter filter cupcakes ;;
let string_explode (s : string) : char list = List.fold_right (fun num chars -> (String.get s num :: chars)) (tabulate (fun x -> x) (String.length s)) [];;
let string_implode (l : char list) : string = let addChar (s : string) (c : char) = s ^ Char.escaped c in List.fold_left addChar "" l;;
let evens (max : int) : int list = unfold (fun b -> (b, b + 2)) (fun b -> b >= max) 0;;
let fib (max : int) : int list = unfold (fun b -> ((fst b) + (snd b), ((snd b), ((fst b) + (snd b))))) (fun b -> ((fst b) + (snd b)) >= max) (1,0);;
let pascal (max : int) : int list list = let getNextRow (x: int list) = List.map2 (+) (List.append [0] x) (List.append x [0]) in unfold(fun b -> (b, (getNextRow b))) (fun b -> max < (List.length b)) [1];;
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let containsAllergen (c: cupcake) : bool = let inAllergens ingredient : bool = not(List.exists (fun a -> a = ingredient) allergens ) in let Cupcake (_, _, _, ingreds) = c in List.for_all inAllergens ingreds in List.filter contains...
let string_explode (s : string) : char list = List.fold_right (fun num chars -> (String.get s num :: chars)) (tabulate (fun x -> x) (String.length s)) [];;
let string_implode (l : char list) : string = let addChar (s : string) (c : char) = s ^ Char.escaped c in List.fold_left addChar "" l;;
let evens (max : int) : int list = unfold (fun b -> (b, b + 2)) (fun b -> b >= max) 0;;
let fib (max : int) : int list = let getNextValue tuple = ((fst tuple) + (snd tuple), ((snd tuple), ((fst tuple) + (snd tuple)))) in unfold getNextValue (fun b -> ((fst b) + (snd b)) >= max) (1,0);;