View difference between Paste ID: p5Va4z5p and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
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 |