SHARE
TWEET

Juliet

a guest Aug 14th, 2010 59 Never
  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
RAW Paste Data
Top