From af1dfcd39ff93e0c8cf2da2fd15b39b7ad6adc3b Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Thu, 20 Oct 2016 06:46:53 +0300 Subject: [PATCH] concurrency/generators: remove leftover implementation --- concurrency/generators.go | 43 --------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 concurrency/generators.go diff --git a/concurrency/generators.go b/concurrency/generators.go deleted file mode 100644 index 5b2b8b2..0000000 --- a/concurrency/generators.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "fmt" -) - -//FibonacciClosure implements fibonacci number generation using closure -func FibonacciClosure() func() int { - a, b := 0, 1 - return func() int { - a, b = b, a+b - return a - } -} - -//FibonacciChan implements fibonacci number generation using channel -func FibonacciChan(n int) chan int { - c := make(chan int) - - go func() { - a, b := 0, 1 - for i := 0; i < n; i++ { - c <- b - a, b = b, a+b - } - close(c) - }() - - return c -} - -func main() { - //closure - nextFib := FibonacciClosure() - for i := 0; i < 20; i++ { - fmt.Println(nextFib()) - } - - //channel - for i := range FibonacciChan(20) { - fmt.Println(i) - } -}