Created
June 7, 2011 03:08
-
-
Save AlexCuse/1011615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Seq | |
#light | |
let merge (s1:seq<'a>) (s2:seq<'a>) = | |
let rec innerMerge s1 s2 = | |
seq { | |
match s1, s2 with | |
| LazyList.Cons(h1, t1), LazyList.Cons(h2, t2) -> | |
yield h1 | |
yield h2 | |
yield! innerMerge s1 s2 | |
| LazyList.Cons(h1, t1), LazyList.Nil -> | |
yield h1 | |
yield! innerMerge s1 s2 | |
| LazyList.Nil, LazyList.Cons(h2, t2) -> | |
yield h2 | |
yield! innerMerge s1 s2 | |
| LazyList.Nil, LazyList.Nil -> | |
yield! innerMerge s1 s2 | |
} | |
innerMerge (LazyList.ofSeq s1) (LazyList.ofSeq s2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment