diff options
author | Rob Pike <r@golang.org> | 2009-01-15 17:54:07 -0800 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-01-15 17:54:07 -0800 |
commit | ec57a60bebcacf864189f04e538db6eed25e8286 (patch) | |
tree | 56d8004bbe6a6396df32bfa0b67a427365527356 /doc/progs/sieve.go | |
parent | f4c0107ad4f6e67579347a0f99b8e9fa470f985a (diff) | |
download | golang-ec57a60bebcacf864189f04e538db6eed25e8286.tar.gz |
casify tutorial examples
will bring document in line in a later CL, which may include revisiting some of the names
R=rsc
DELTA=58 (0 added, 0 deleted, 58 changed)
OCL=22906
CL=22908
Diffstat (limited to 'doc/progs/sieve.go')
-rw-r--r-- | doc/progs/sieve.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/progs/sieve.go b/doc/progs/sieve.go index 22e14535e..1e472948e 100644 --- a/doc/progs/sieve.go +++ b/doc/progs/sieve.go @@ -5,7 +5,7 @@ package main // Send the sequence 2, 3, 4, ... to channel 'ch'. -func Generate(ch chan int) { +func generate(ch chan int) { for i := 2; ; i++ { ch <- i // Send 'i' to channel 'ch'. } @@ -13,7 +13,7 @@ func Generate(ch chan int) { // Copy the values from channel 'in' to channel 'out', // removing those divisible by 'prime'. -func Filter(in, out chan int, prime int) { +func filter(in, out chan int, prime int) { for { i := <-in; // Receive value of new variable 'i' from 'in'. if i % prime != 0 { @@ -25,12 +25,12 @@ func Filter(in, out chan int, prime int) { // The prime sieve: Daisy-chain Filter processes together. func main() { ch := make(chan int); // Create a new channel. - go Generate(ch); // Start Generate() as a goroutine. + go generate(ch); // Start Generate() as a goroutine. for { prime := <-ch; print(prime, "\n"); ch1 := make(chan int); - go Filter(ch, ch1, prime); + go filter(ch, ch1, prime); ch = ch1 } } |