Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* b *)
- let czyIstniejeFL f xs = List.fold_left (fun x y -> if f y then x || true else x || false) false xs;;
- (* c *)
- let czyIstniejeFR f xs = List.fold_right (fun x y -> if f x then true || y else false || y) xs false;;
- (*Zadanie 4*)
- let rec merge l x y = match (x,y) with
- | ([],_) -> y
- | (_,[]) -> x
- | (h1::t1, h2::t2) ->
- if l h1 h2
- then h1::(merge l t1 y)
- else h2::(merge l x t2);;
- let rec split x y z = match x with
- | [] -> (y,z)
- | x::xs -> split xs z (x::y);;
- let rec mergesort l x = match x with
- | ([] | _::[]) -> x
- | _ -> let (pri,seg) = split x [] []
- in merge l (mergesort l pri) (mergesort l seg);;
- mergesort (>) [2;6;1;8];;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement