Advertisement
Guest User

Juliet

a guest
Aug 14th, 2010
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.40 KB | None | 0 0
  1. open Microsoft.FSharp.Collections.LazyList
  2. let rec merge a b =
  3.     let cons' x f = LazyList.consDelayed x f
  4.     match a, b with
  5.     | (Cons(x, xs) as left), (Cons(y, ys) as right) ->
  6.         if x < y then cons' x (fun () -> merge xs right)
  7.         elif x > y then cons' y (fun () -> merge left ys)
  8.         else cons' x (fun () -> cons' y (fun() -> merge xs ys))
  9.     | Nil, ys -> ys
  10.     | xs, Nil -> xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement