mirror of
https://github.com/golang/go.git
synced 2025-11-01 09:10:57 +00:00
convert tests; nothing interesting.
R=r OCL=23012 CL=23014
This commit is contained in:
parent
9f4a27cbe6
commit
f48cbfdf56
82 changed files with 292 additions and 296 deletions
|
|
@ -7,7 +7,7 @@
|
|||
package main
|
||||
|
||||
// Send the sequence 2, 3, 4, ... to channel 'ch'.
|
||||
func Generate(ch chan<- int) {
|
||||
export func Generate(ch chan<- int) {
|
||||
for i := 2; ; i++ {
|
||||
ch <- i // Send 'i' to channel 'ch'.
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ func Generate(ch chan<- int) {
|
|||
|
||||
// Copy the values from channel 'in' to channel 'out',
|
||||
// removing those divisible by 'prime'.
|
||||
func Filter(in <-chan int, out chan<- int, prime int) {
|
||||
export func Filter(in <-chan int, out chan<- int, prime int) {
|
||||
for {
|
||||
i := <-in; // Receive value of new variable 'i' from 'in'.
|
||||
if i % prime != 0 {
|
||||
|
|
@ -25,7 +25,7 @@ func Filter(in <-chan int, out chan<- int, prime int) {
|
|||
}
|
||||
|
||||
// The prime sieve: Daisy-chain Filter processes together.
|
||||
func Sieve() {
|
||||
export func Sieve() {
|
||||
ch := make(chan int); // Create a new channel.
|
||||
go Generate(ch); // Start Generate() as a subprocess.
|
||||
for {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue