blob: 1a462acaf52b148d9b0b184a3d7d578e14f6ba85 [file] [log] [blame]
// +build OMIT ignore
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
f, g := 1, 0
return func() int {
f, g = g, f+g
return f
}
}
func main() {
f := fibonacci()
for i := 0; i < 10; i++ {
fmt.Println(f())
}
}