Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Juliet

By: a guest on Aug 14th, 2010  |  syntax: OCaml  |  size: 0.40 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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