1
0
mirror of https://github.com/tmrts/go-patterns.git synced 2025-02-16 12:33:16 +03:00
This commit is contained in:
legendtkl 2016-09-08 08:16:42 +08:00
parent 4ec77fe119
commit 8e6c437754
2 changed files with 3 additions and 3 deletions

View File

@ -3,4 +3,4 @@
[Generator](https://en.wikipedia.org/wiki/Generator_(computer_programming)) is a special routine that can be used to control the iteration behavior of a loop.
# Implementation and Example
With Go language, we can implement generator in two ways: channel and closure. Fibnacci example can be found in [generators.go](generators.go).
With Go language, we can implement generator in two ways: channel and closure. Fibonacci number generation example can be found in [generators.go](generators.go).

View File

@ -4,7 +4,7 @@ import (
"fmt"
)
//FibonacciClosure implements fibonacci number generatoin using closure
//FibonacciClosure implements fibonacci number generation using closure
func FibonacciClosure() func() int {
a, b := 0, 1
return func() int {
@ -13,7 +13,7 @@ func FibonacciClosure() func() int {
}
}
//FibonacciChan implements fibonacci number generatoin using channel
//FibonacciChan implements fibonacci number generation using channel
func FibonacciChan(n int) chan int {
c := make(chan int)