text
stringlengths 0
601k
|
---|
let string_implode (l : char list) : string = List.fold_right (fun x -> (^) (Char.escaped x)) l "";; |
let evens (max : int) : int list = unfold (fun (x, y) -> (x, (y, y+2))) (fun (x, y) -> x >= max) (0, 2);; |
let fib (max : int) : int list = unfold (fun (x, y) -> (x, (y, x+y))) (fun (x, y) -> x >= max) (1, 1);; |
let pascal (max : int) : int list list = unfold (fun x -> (x, List.map2 (+) (0 :: x) (x @ [0]))) (fun y -> (List.length y) > max) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun (Cupcake (_, _, _, l)) -> (List.for_all (fun x -> not (List.exists (fun y -> y = x) allergens)) l)) cupcakes;; |
let string_explode (s : string) : char list = tabulate (fun b -> String.get s b) (String.length s);; |
let string_implode (l : char list) : string = String.concat "" (tabulate ( fun b -> Char.escaped (List.nth l b) ) (List.length 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(+) ([0]@b) (b@[0])) ) (fun b -> max < List.length b ) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let check (cc : cupcake)= let Cupcake (p, q, r, s) = cc in List.for_all (fun x -> not (List.exists (fun y -> y = x ) allergens) ) s in List.filter (fun c -> check c ) 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 -> b > max-1) 0;; |
let fib (max : int) : int list = unfold (fun (a, b) -> b, (b, a+b)) (fun (a, b) -> max <= b) (0,1);; |
let pascal (max : int) : int list list = unfold (fun (a, b) -> (a, (b, List.map2 (+) (0 :: b)(b @ [0])))) (fun (a, b) -> max < List.length a) ([1], [1;1]);; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let ingredientDoesNotExistInAllergens (allergens : ingredient list) (ingredient2Eval : ingredient) : bool = not (List.exists (fun x -> x = ingredient2Eval) allergens) in let cupcakeChecker (allergens : ingredient list) (cpk : cupcake) : bool = let Cupcake (_,_,_,ingredient) = cpk in List.for_all (ingredientDoesNotExistInAllergens allergens) ingredient in List.filter(cupcakeChecker allergens) cupcakes ;; |
let string_explode (s : string) : char list = let n = String.length s in tabulate (String.get s) (n);; |
let string_implode (l : char list) : string = let convert x = Char.escaped(x) in let list = List.map convert l in List.fold_left (fun acc x -> acc ^ x) "" list;; |
let evens (max : int) : int list = unfold (fun x -> (x, x+2)) (fun x -> x >= max) 0;; |
let fib (max : int) : int list = let check = (fun (x,y) -> max <= x) in unfold (fun (x,y) -> (x,(y,x+y))) check (1,1);; |
let pascal (max : int) : int list list = let check = (fun x -> List.length x > max) in unfold (fun x -> x, List.map2 (+) (0::x) (x@[0])) check [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = if List.length allergens >= 0 then let allergens_free c = not(List.exists (fun x -> c = x) allergens) in List.filter (fun (Cupcake(_,_,_,ingredients)) -> List.for_all allergens_free ingredients) cupcakes else[];; |
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 l = List.map (Char.escaped) l in List.fold_left (^) "" 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) -> (b, (b, a+b))) (fun b -> let (q,r) = b in max <= r) (0,1);; |
let pascal (max : int) : int list list = unfold (fun (a: int list) -> (a, (List.map2 (+) (0 :: a) (List.rev (0 :: a))))) (fun a -> max < List.length a) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let rec loop_to_find_all (cuppycake : cupcake) = match cuppycake with | Cupcake (p, w, c, []) -> false | Cupcake (p, w, c, h::tail) -> ((List.exists (fun x -> x=h) allergens) && (loop_to_find_all (Cupcake(p,w,c,tail)))) in List.filter loop_to_find_all 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 l = List.map (Char.escaped) l in List.fold_left (^) "" 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) -> (b, (b, a+b))) (fun b -> let (q,r) = b in max <= r) (0,1);; |
let pascal (max : int) : int list list = unfold (fun (a: int list) -> (a, (List.map2 (+) (0 :: a) (List.rev (0 :: a))))) (fun a -> max < List.length a) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake(p,w,c,lst) -> match lst with | [] -> true | h::t -> (List.for_all (fun ingredient -> not (List.exists (fun allergen -> allergen = ingredient) allergens) ) lst) ) cupcakes ;; |
let string_explode (s : string) : char list = let string_get (i: int) = String.get s i in tabulate string_get (String.length s);; |
let string_implode (l : char list) : string = let concat_char (c: char) (s: string) = (Char.escaped c) ^ s in List.fold_right concat_char 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) -> (b, (b, a+b))) (fun (a, b) -> max <= b) (0, 1);; |
let pascal (max : int) : int list list = unfold (fun l -> (l, List.append (List.append [1] (List.map2 (+) (List.tl l) (List.rev (List.tl (List.rev l))))) [1])) (fun l -> max+1 <= List.length l) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake (_, _, _, ingreds) -> List.for_all (fun i -> not (List.exists (fun e -> e = i) allergens)) ingreds) cupcakes;; |
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s) ;; |
let string_implode (l : char list) : string = let concatenated a b = a ^ Char.escaped b in List.fold_left (concatenated) "" l ;; |
let evens (max : int) : int list = unfold (fun b -> (b, b + 2)) (fun a -> a >= max) 0 ;; |
let fib (max : int) : int list = unfold (fun (a, b) -> (a, (b, (a + b)))) (fun (a, b) -> a >= max) (1,1) ;; |
let pascal (max : int) : int list list = let aux (x: int list) : (int list * int list) = let y = [0] @ x @ [0] in let rec auxu (y: int list) (cur: int list): int list * int list = match y with | [] -> (x, cur) | y :: ys -> match ys with | [] -> (x, cur) | t :: ts -> auxu (ys) ((y + t) :: cur) in auxu y [] in unfold aux (fun array -> List.length(array) >= (max + 1)) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let allergy i = not (List.exists ((=) i) allergens) in let filter (Cupcake (price, weight, calories, ingredients)) = List.for_all (allergy) ingredients in List.filter (filter) cupcakes ;; |
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s) ;; |
let string_implode (l : char list) : string = let concatenated a b = a ^ Char.escaped b in List.fold_left (concatenated) "" l ;; |
let evens (max : int) : int list = unfold (fun b -> (b, b + 2)) (fun a -> ( >= ) a max) 0 ;; |
let fib (max : int) : int list = unfold (fun (a, b) -> (a, (b, (a + b)))) (fun (a, b) -> ( >= ) a max) (1,1) ;; |
let pascal (max : int) : int list list = let aux (x: int list) : (int list * int list) = let y = 0 :: x @ [0] in let rec auxu (x: int list) (y: int list) (cur: int list): int list * int list = match y with | [] -> (x, cur) | y :: ys -> match ys with | [] -> (x, cur) | t :: ts -> auxu x (t :: ts) ((y + t) :: cur) in auxu x y [] in unfold aux (fun array -> List.length(array) >= (max + 1)) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let allergy a = not (List.exists ((=) a) allergens) in let filter (Cupcake (_, _, _, ingredients)) = List.for_all (allergy) ingredients in List.filter (filter) cupcakes ;; |
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s) ;; |
let string_implode (l : char list) : string = let concatenated a b = a ^ Char.escaped b in List.fold_left (concatenated) "" l ;; |
let evens (max : int) : int list = let aux (x: int): int * int = let value = (x, x + 2) in value in let auxu (y: int) (maximum : int): bool = let boolean = ( >= ) y maximum in boolean in unfold aux (fun a -> (auxu a max)) 0 ;; let getfirst(a, _) = a;; let getsecond(_, b) = b;; |
let fib (max : int) : int list = let aux (x: int * int) : int * (int * int) = let first = getfirst x in let second = getsecond x in (first, (second, (first + second))) in let auxu (x: int * int) (maximum: int) : bool = let firstx = getfirst x in ( >= ) firstx maximum in unfold (fun (a, b) -> (aux (a, b))) (fun (a, b) -> auxu (a, b) max) (1,1) ;; |
let pascal (max : int) : int list list = let aux (x: int list) : (int list * int list) = let y = 0 :: x @ [0] in let rec auxu (x: int list) (y: int list) (cur: int list): int list * int list = match y with | [] -> (x, cur) | y :: ys -> match ys with | [] -> (x, cur) | t :: ts -> auxu x (t :: ts) ((y + t) :: cur) in auxu x y [] in let auxy (array: int list) (maximum: int): bool = let size = List.length(array) in not (size < (maximum + 1)) in unfold (aux) (fun array -> (auxy array max)) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let allergy a = not (List.exists ((=) a) allergens) in let filter (Cupcake (_, _, _, ingredients)) = List.for_all (allergy) ingredients in List.filter (filter) cupcakes ;; |
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s) ;; |
let string_implode (l : char list) : string = let concatenated a b = a ^ Char.escaped b in List.fold_left (concatenated) "" l ;; |
let evens (max : int) : int list = let aux (x: int): int * int = let value = (x, x + 2) in value in let auxu (y: int) (maximum : int): bool = let boolean = ( >= ) y maximum in boolean in unfold aux (fun a -> (auxu a max)) 0 ;; let getfirst(a, _) = a;; let getsecond(_, b) = b;; |
let fib (max : int) : int list = let aux (x: int * int) : int * (int * int) = let first = getfirst x in let second = getsecond x in (first, (second, (first + second))) in let auxu (x: int * int) (maximum: int) : bool = let firstx = getfirst x in ( >= ) firstx maximum in unfold (fun (a, b) -> (aux (a, b))) (fun (a, b) -> auxu (a, b) max) (1,1) ;; |
let pascal (max : int) : int list list = let aux (x: int list) : (int list * int list) = let y = 0 :: x @ [0] in let rec auxu (x: int list) (y: int list) (cur: int list): int list * int list = match y with | [] -> (x, cur) | y :: ys -> match ys with | [] -> (x, cur) | t :: ts -> auxu x (t :: ts) ((y + t) :: cur) in auxu x y [] in let auxy (array: int list) (maximum: int): bool = let size = List.length(array) in not (size < (maximum + 1)) in unfold (aux) (fun array -> (auxy array max)) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let allergy a = not (List.exists ((=) a) allergens) in let filter (Cupcake (_, _, _, ingredients)) = List.for_all (allergy) ingredients in List.filter (filter) cupcakes ;; |
let string_explode (s : string) : char list = let getCharAtIndex (s : string) (index : int) : char = s.[index] in tabulate (getCharAtIndex s) (String.length s);; |
let string_implode (l : char list) : string = List.fold_left (fun acc c -> acc ^ (String.make 1 c)) (String.create (0)) l;; |
let evens (max : int) : int list = unfold (fun e -> (e, e+2)) ((<=) max) 0;; |
let fib (max : int) : int list = unfold (fun (e,b) -> (e, (e+b,e))) (fun (e,b) -> max <= e) (1,0);; |
let pascal (max : int) : int list list = let next_row nthRow = List.map2 (+) ( 0 :: nthRow) (nthRow @ [0]) in unfold (fun (e,index) -> (e, (next_row e, index+1))) (fun (e,index) -> max <= index) ([1], 0);; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (function Cupcake (_, _, _, ingredients) -> List.for_all (fun allergen -> not(List.exists ((=) allergen) ingredients)) allergens) cupcakes;; |
let string_explode (s : string) : char list = let s_len = String.length s in tabulate (String.get s) s_len;; |
let string_implode (l : char list) : string = let s_list = List.map Char.escaped l in String.concat "" s_list;; |
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, a+b))) (fun (a,b) -> max <= a) (1,1);; |
let pascal (max : int) : int list list = let p b = let l1 = List.rev(List.tl(List.rev(b))) in let l2 = List.tl(b) in let l = List.map2 (+) l1 l2 in let l_left = 1 :: l in let l_right = 1 :: List.rev(l_left) in (b, List.rev(l_right)) in unfold (p) (fun b -> (max+1) <= List.length b) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let f (c: cupcake) = let ingredients = let Cupcake (_,_,_,ingredients) = c in ingredients in List.for_all (fun b -> not (List.exists ((==) b) allergens)) ingredients in List.filter f cupcakes;; |
let string_explode (s : string) : char list = let get_word (n : int) = String.get s n in tabulate get_word (String.length s);; |
let string_implode (l : char list) : string = let concat (c1: string) (c2: char) : string = c1 ^ (Char.escaped c2) in List.fold_left concat "" 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 = let chop_last (d : int list) = List.rev (List.tl (List.rev d)) in let polish (d : int list) = List.rev (1 :: (List.rev (1 :: d))) in let build (alist : int list) : (int list * int list) = match List.length alist with |0 -> ([], []) |1 -> ([1], [1;1]) |2 -> ([1;1], [1;2;1]) |_ -> (alist, polish (List.map2 (+) (List.tl alist) (chop_last alist))) in unfold (fun b -> build b) (fun b -> (max + 1) <= (List.length b)) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let unroll = function | Cupcake (p, w, c, i) -> i in let g (i : ingredient) = let h (allergen : ingredient) = not (allergen = i) in List.for_all h allergens in let f (cupcakey : cupcake) : bool = if List.length (unroll cupcakey) = -1 then List.exists g (unroll cupcakey) else List.for_all g (unroll cupcakey) in List.filter f cupcakes ;; |
let string_explode (s : string) : char list = match s with | "" -> [] | _ -> tabulate (String.get s) (String.length s);; |
let string_implode (l : char list) : string = match l with | [] -> "" | _ -> List.fold_left (fun beggin leftP -> beggin ^ (Char.escaped leftP)) "" l;; |
let evens (max : int) : int list = unfold (fun b -> (b,b+2)) ((<=) max) 0;; |
let fib (max : int) : int list = unfold (fun b -> (snd b, (snd b,(fst b)+(snd b)))) (fun b -> max <= (snd b)) (0,1);; |
let pascal (max : int) : int list list = unfold (fun b -> (b, 1::(List.map2 (+) b ((List.tl b)@[0])))) (fun b -> max < List.length b) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun cupcake -> let Cupcake (_,_,_,ingred) = cupcake in (List.for_all (fun allergen -> not (List.exists (fun a -> a == allergen) ingred)) allergens)) 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 = String.concat "" (List.map (String.make 1) 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, b+a))) (fun (a,b) -> max <= a) (1, 1);; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let h = function Cupcake (_,_,_,ingredients) -> ingredients in let g ingredient= not(List.exists (fun allergen -> allergen == ingredient) allergens) in let f cupcake = List.for_all g (h cupcake) in List.filter f cupcakes;; |
let string_explode (s : string): char list = raise NotImplemented;; |
let string_implode (l : char list) : string = raise NotImplemented let rec fib_aux n a b = if n=0 then b else if n=1 then b else fib_aux (n-1) (b) (a+b) ;; let fib_tl n = fib_aux n 1 1 ;; |
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 b -> (b, b+b)) (fun b -> max <= b+b) 0;; |
let pascal (max : int) : int list list = raise NotImplemented;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter( function Cupcake(_,_,_,ingred_list) -> List.for_all (fun ingredient-> not(List.exists ((=) ingredient) ingred_list)) allergens) cupcakes ;; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.