Last active
April 8, 2018 11:20
-
-
Save just1689/72facfc75ac86556814a906f42227812 to your computer and use it in GitHub Desktop.
Process a channel of input and write results to a channel
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
func sq(in <-chan int) <-chan int { | |
out := make(chan int) | |
go func() { | |
for n := range in { | |
out <- n * n | |
} | |
close(out) | |
}() | |
return out | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment