fix: coding style and file format for chapter 6.

This commit is contained in:
Bo-Yi Wu
2017-02-11 12:24:19 +08:00
parent 0dee646030
commit 72c3839734
11 changed files with 290 additions and 279 deletions

View File

@@ -1,20 +1,20 @@
package main
// fib returns a function that returns
// successive Fibonacci numbers.
func fib() func() int {
a, b := 1, 1
return func() int {
a, b = b, a+b
return b
}
}
func main() {
f := fib()
// Function calls are evaluated left-to-right.
// println(f(), f(), f(), f(), f())
for i:=0; i<=9; i++ {
println(i+2, f() )
}
}
package main
// fib returns a function that returns
// successive Fibonacci numbers.
func fib() func() int {
a, b := 1, 1
return func() int {
a, b = b, a+b
return b
}
}
func main() {
f := fib()
// Function calls are evaluated left-to-right.
// println(f(), f(), f(), f(), f())
for i := 0; i <= 9; i++ {
println(i+2, f())
}
}