text
stringlengths 0
601k
|
---|
let pascal (max : int) : int list list = if(max<1) then [] else let f (l : int list) : (int list * int list) = if(l==[]) then ([1],[1]) else ((List.map2 (+) (0::l) (l@[0])),(List.map2 (+) (0::l) (l@[0]))) in let reachedBottom (l:int list) : bool = (List.length l + 1) > max in unfold f reachedBottom [];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let filterFunction1 (Cupcake(p,w,c,l)) : bool = let filterFunction2 (a:ingredient) : bool = let filterFunction3 (i:ingredient) : bool = (i=a) in not (List.exists filterFunction3 l) in List.for_all filterFunction2 allergens in List.filter filterFunction1 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 = if(max<1) then [] else let plusTwo (x:int) : (int*int) = (x+2,x+2) in let reachedMax (x:int) :bool = (x+2>=max) in unfold plusTwo reachedMax (-2);; |
let fib (max : int) : int list = if(max<2)then [] else let sumPair ((x,y) : (int*int)) : (int*(int*int)) = if(x=0 && y=0) then (1,(0,1)) else (x+y,(y,x+y)) in let reachedSummit ((x,y):(int*int)) : bool = (x+y>=max) in unfold sumPair reachedSummit (0,0);; |
let pascal (max : int) : int list list = if(max<1) then [] else let f (l : int list) : (int list * int list) = if(l==[]) then ([1],[1]) else ((List.map2 (+) (0::l) (l@[0])),(List.map2 (+) (0::l) (l@[0]))) in let reachedBottom (l:int list) : bool = (List.length l + 1) > max in unfold f reachedBottom [];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let filterFunction1 (Cupcake(p,w,c,l)) : bool = let filterFunction2 (a:ingredient) : bool = let filterFunction3 (i:ingredient) : bool = (i=a) in not (List.exists filterFunction3 l) in List.for_all filterFunction2 allergens in List.filter filterFunction1 cupcakes;; |
let string_explode (s : string) : char list = tabulate (String.get s) (String.length s);; |
let string_implode (l : char list) : string = let s = List.map (Char.escaped) l in List.fold_left (^) "" s;; |
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 = if max <= 0 then [] else unfold (fun l -> let l1 = List.tl (l) in let l2 = List.rev l1 in let l3 = List.map2 (+) l1 l2 in let l4 = List.append l3 [1] in let l5 = List.rev_append l4 [1] in (l, l5)) (fun l -> max < (List.length l)) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = if List.length cupcakes = 0 then [] else List.filter(function Cupcake (_, _, _, ingredients) -> List.for_all(fun a -> List.exists((!=) a) ingredients) allergens) cupcakes;; |
let string_explode (s : string) : char list = let n = String.length s in let get_char = String.get s in tabulate get_char n;; |
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)) (fun b -> max <= b) 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 (+) (List.tl b) (List.rev (List.tl b))@[1])) (fun b -> max < List.length b) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let ingredient_list cupcake = let Cupcake (_,_,_,ingredients) = cupcake in ingredients in List.filter (fun cupcake -> List.for_all (fun ingredient -> not (List.exists (fun allergen -> ingredient = allergen) allergens)) (ingredient_list cupcake)) cupcakes;; |
let string_explode (s : string) : char list = if s = "" then (); tabulate (String.get s) (String.length s) ;; |
let string_implode (l : char list) : string = if l = [] then (); 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 b -> (fst b, (fst b + snd b, fst b))) (fun b -> max <= fst b) (1,0) ;; |
let pascal (max : int) : int list list = unfold (fun b -> (b, (List.map2 (+) (List.append [0] b) (List.append b [0])))) (fun b -> max < List.length b) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter ( function Cupcake (_,_,_,ilist) -> List.for_all (function ing -> not(List.exists (function aller -> (ing = aller)) allergens)) ilist) cupcakes ;; |
let string_explode (s : string) : char list = tabulate (fun i -> s.[i] ) (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)) (fun b -> max <= b) 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 -> (a, 1:: List.map2 (+) a (List.rev(0::List.rev(List.tl a))))) (fun a -> max < List.length a) [1] let zpMatch = fun (l1, l2) -> let (x::xs, y::ys) = (l1, l2) in ((x, y), (xs, ys)) let zpStop (l1, l2) = match l1, l2 with | [], _ -> true | _, [] -> true | _, _ -> false;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = if(allergens = []) then cupcakes else List.filter(fun (Cupcake (_,_,_,l)) -> List.for_all (fun elx -> not (List.exists (fun ely -> ely = elx) 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, (a + b)))) (fun (a, b) -> max <= a) (1, 1);; |
let pascal (max : int) : int list list = unfold (fun b -> (b, (List.map2 (+) (List.append [0] b) (List.append b [0])))) (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 item -> not ( List.exists ((==) item) ingredients)) 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_left (^) "" (List.map Char.escaped l) ;; |
let evens (max : int) : int list = let plus_deux i = (i + 2, i + 2) in let arrete nombre = nombre >= max - 2 in unfold (plus_deux) (arrete) (-2) ;; |
let fib (max : int) : int list = let fibonacci_fonction ((a, b) : int * int) = let somme = a + b in (b, (b, somme)) in let arrete ((a, b) : int * int) : bool = b>= max in unfold fibonacci_fonction (arrete) (0, 1) ;; |
let pascal (max : int) : int list list = let triangle (ligne_derniere : int list) : (int list * int list) = let nouvelle_ligne = (List.map2 (+) (ligne_derniere @ [0]) (0 :: ligne_derniere)) in (ligne_derniere, nouvelle_ligne) in let arrete ligne_derniere = List.length ligne_derniere > max in unfold triangle arrete [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let condition (Cupcake (_, _, _, ingredients): cupcake) : bool = let avoir_des_allergenes un_ingredient : bool = List.exists((=) un_ingredient) allergens in List.for_all (fun a -> not (avoir_des_allergenes a)) ingredients in List.filter condition 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 = 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 x -> max < List.length x) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter(fun (Cupcake (_,_,_,l)) -> List.for_all ( fun e1 -> not (List.exists ( (=) e1 ) allergens ) ) l ) cupcakes ;; |
let rec listCon index len s = match index = len with | true -> [] | false -> (String.get s index) :: listCon (index+1) len s let func (s: string) (c: char) = s ^ Char.escaped c;; |
let string_explode (s : string) : char list = List.fold_left func "" []; listCon 0 (String.length s) s let smoosh (s: string) (c: char) = s ^ Char.escaped c ;; |
let string_implode (l : char list) : string = List.fold_left smoosh "" l let getT2 (a, b) = b;; |
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 -> (int_of_float ((((((1. +. (sqrt 5.)) /. 2.) ** float_of_int b) -. (((1. -. (sqrt 5.)) /. 2.) ** float_of_int b)) /. sqrt 5.) ), b+1)) (fun b -> max <= int_of_float ( (((((1. +. (sqrt 5.)) /. 2.) ** float_of_int b) -. (((1. -. (sqrt 5.)) /. 2.) ** float_of_int b)) /. sqrt 5.)) ) 1;; |
let pascal (max : int) : int list list = unfold (fun b -> ([], b+2)) (fun b -> (<=) max b) 0 let getFirst (l: 'a list) : 'a = match l with | x::xs -> x | _ -> failwith "empty list";; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let rec cycle_cakes (al : ingredient list) (cx : cupcake list) (cT : cupcake list) = match cx with | [] -> cT | c::xs -> cycle_cakes al xs ( let rec cycle_ingredients (al : ingredient list) (cT : cupcake list) = match al with | [] -> cT | ingredient::ys -> cycle_ingredients ys ( if ( let inList a l = let search x = match x=a with | true -> true | false -> false in List.exists search (getT4 c) in inList ingredient (getT4 c) ) then let removeIt a l = let remove_el x = match x!=a with | true -> true | false -> false in List.filter remove_el cT in removeIt c cT else if ( let notInList a l = let look x = match x!=a with | true -> true | false -> false in List.for_all look (getT4 c) in notInList ingredient (getT4 c) ) then cT else cT ) in cycle_ingredients al cT ) in cycle_cakes allergens cupcakes cupcakes;; |
let string_explode (s : string) : char list = let get = String.get in let f = get s in let len = String.length s in tabulate f len ;; |
let string_implode (l : char list) : string = let fold c = (^)(Char.escaped c) in let str = List.fold_right fold l (fold '0' "") in String.sub str 0 (List.length l) ;; let len = List.length;; let rm = List.tl ;; let rev = List.rev;; let h = List.hd;; let t = List.tl;; |
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 pl = List.map2 (+) in let rev = List.rev in let len = List.length in let rm = List.tl in let f = fun (a,b) -> (a,(b,[1]@pl (rm b) (rev (rm b))@[1])) in let stop = fun (a,b) -> max <= len a-1 in unfold f stop ([1],[1;1]) ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let p1 i = not(List.exists((==) i) allergens) in let p2 ck = List.for_all (p1) (get_list ck) in List.filter p2 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 a -> (a, a + 2)) (fun a -> a >= max) 0;; |
let fib (max : int) : int list = unfold (fun (c, d) -> (c, (d, c+d))) (fun (c, d) -> max <= c) (1, 1);; |
let pascal (max : int) : int list list = unfold (fun (n, a, b) -> (a, (n+1, b, (List.fold_left List.append [] [[1]; (List.map2 (+) (List.rev (List.tl b)) (List.tl b)); [1]]) ) ) ) (fun (n, a, b) -> n >= max) (0, [1], [1;1]);; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter (fun x -> let Cupcake(a,b,c,d) = x in (List.for_all (fun y -> (not (y==true))) [(List.exists (fun n -> List.mem n allergens) d)] )) cupcakes;; |
let string_explode (s : string) : char list = if s = "" then [] else tabulate (String.get s) (String.length s);; |
let string_implode (l: char list) : string = match l with | [] -> "" | chr -> List.fold_left (^) "" (List.map Char.escaped chr);; |
let evens (max : int) : int list = unfold (fun b->(b,b+2)) (fun b-> max <= b) 0;; |
let fib (max : int) : int list = raise NotImplemented ;; let rec fib_aux n a b = if n = 0 then a else fib_aux (n - 1) b (a + b) ;; let fib_tl n = if n < 0 then domain() else let rec fib_aux n a b = if n = 0 then a else fib_aux (n - 1) b (a + b) in fib_aux n 1 1;; |
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 (a) -> (a, (List.map2 (+) (0::a) (a @ [0])))) (fun (a) -> max < (List.length a)) [1];; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let isolation cupcakes = let Cupcake (price,weight,calories,ingredient) = cupcakes in ingredient in List.filter (fun cupcake -> (List.for_all (fun allergy -> not (List.exists (fun x -> x = allergy) (isolation cupcake))) 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 (String.make 1) 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, a+b))) (fun (a, b) -> max <= a) (1, 1) ;; |
let pascal (max : int) : int list list = if max = 0 then [] else unfold (fun b -> (b, (List.map2 (+) (0 :: b) (List.tl [1]@b@[0])))) (fun b -> (List.length b) > max) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = if allergens = [] then cupcakes else List.filter ( function Cupcake (_,_,_,ingredients) -> if ingredients = [] then true else List.for_all (fun ingredient -> not (List.exists ((=) 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 b -> (b, b+2)) (fun b -> max <= b) 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 = let get_next (l : int list): int list = List.map2 (+) (0 :: l) (List.rev (0 :: List.rev l)) in unfold (fun l -> (l, get_next l)) (fun l -> max < List.length l) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let has_allergen (c : cupcake): bool = let Cupcake(p, w, cal, ingred_lst) = c in let rec has_each allergens = match allergens with | [] -> [true] | x :: xs -> List.for_all (fun ingred -> ingred != x) ingred_lst :: has_each xs in not (List.exists (fun e -> not e) (has_each allergens)) in List.filter (has_allergen) 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 f s c = s^(Char.escaped c) in List.fold_left f "" 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 , a + b)))(fun (a,b) -> max <= a) (1,1) ;; let row r = List.map2 (+) (0 :: r) (r @ [0]);; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = List.filter ( fun (Cupcake (_,_,_,i)) -> (List.for_all ( fun a -> (not (List.exists (fun b -> (b = a)) i) )) 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 = let f = List.map Char.escaped l in List.fold_right (^) f "" ;; |
let evens (max : int) : int list = unfold (fun b -> (b, b+2)) ((<=) max) 0 ;; |
let fib (max : int) : int list = if max < 2 then [] else 1 :: unfold (fun (a,b) -> (a+b, (b,a+b))) (fun (a,b) -> max <= a+b) (0,1) ;; |
let pascal (max : int) : int list list = let f = (fun l -> (l, List.map2 (+) (0 :: l) (l @ [0]))) in unfold f (fun l -> max < (List.length l)) [1] ;; |
let allergy_free (allergens : ingredient list) (cupcakes : cupcake list) : cupcake list = let safe (c:cupcake) (i:ingredient) : bool = let Cupcake (x,y,z,l) = c in not (List.exists (fun a -> (a = i)) l) in let check_safe (allergens : ingredient list) (c : cupcake) : bool = List.for_all (safe c) allergens in List.filter (check_safe allergens) cupcakes;; |
let string_explode (s : string) : char list = let thru_string (i : int) : char = String.get s i in tabulate (thru_string) (String.length s);; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.