Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created June 7, 2011 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCuse/1011615 to your computer and use it in GitHub Desktop.
Save AlexCuse/1011615 to your computer and use it in GitHub Desktop.
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