Commit a5e10edc authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

doc/play: don't use println in examples

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6849105
parent 2e73453a
package main package main
import "fmt"
// fib returns a function that returns // fib returns a function that returns
// successive Fibonacci numbers. // successive Fibonacci numbers.
func fib() func() int { func fib() func() int {
...@@ -13,5 +15,5 @@ func fib() func() int { ...@@ -13,5 +15,5 @@ func fib() func() int {
func main() { func main() {
f := fib() f := fib()
// Function calls are evaluated left-to-right. // Function calls are evaluated left-to-right.
println(f(), f(), f(), f(), f()) fmt.Println(f(), f(), f(), f(), f())
} }
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
package main package main
import "fmt"
// Send the sequence 2, 3, 4, ... to channel 'ch'. // Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) { func Generate(ch chan<- int) {
for i := 2; ; i++ { for i := 2; ; i++ {
...@@ -26,7 +28,7 @@ func main() { ...@@ -26,7 +28,7 @@ func main() {
go Generate(ch) // Launch Generate goroutine. go Generate(ch) // Launch Generate goroutine.
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
prime := <-ch prime := <-ch
print(prime, "\n") fmt.Println(prime)
ch1 := make(chan int) ch1 := make(chan int)
go Filter(ch, ch1, prime) go Filter(ch, ch1, prime)
ch = ch1 ch = ch1
......
...@@ -89,7 +89,7 @@ func solve() bool { ...@@ -89,7 +89,7 @@ func solve() bool {
// see if this new board has a solution // see if this new board has a solution
if solve() { if solve() {
unmove(pos, dir) unmove(pos, dir)
println(string(board)) fmt.Println(string(board))
return true return true
} }
unmove(pos, dir) unmove(pos, dir)
...@@ -102,7 +102,7 @@ func solve() bool { ...@@ -102,7 +102,7 @@ func solve() bool {
// tried each possible move // tried each possible move
if n == 1 && (center < 0 || last == center) { if n == 1 && (center < 0 || last == center) {
// there's only one peg left // there's only one peg left
println(string(board)) fmt.Println(string(board))
return true return true
} }
// no solution found for this board // no solution found for this board
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment