Skip to content

Instantly share code, notes, and snippets.

@campoy
Created Feb 12, 2018
Embed
What would you like to do?
gist 1 for episode 28 of justforfunc
func mergeRec(chans ...<-chan int) <-chan int {
switch len(chans) {
case 0:
c := make(chan int)
close(c)
return c
case 1:
return chans[0]
default:
m := len(chans) / 2
return mergeTwo(
mergeRec(chans[:m]...),
mergeRec(chans[m:]...))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment