concurrency/generator: implement generator pattern

This commit is contained in:
legendtkl
2016-09-06 15:45:18 +08:00
committed by Tamer Tas
parent 90f5b5b1a5
commit d05638adac
3 changed files with 50 additions and 1 deletions

6
concurrency/generator.md Normal file
View File

@@ -0,0 +1,6 @@
# Generator Pattern
[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. Fibonacci number generation example can be found in [generators.go](generators.go).