Skip to content

Instantly share code, notes, and snippets.

@pedromg
pedromg / fibonacci_closure.go
Created June 21, 2017 22:44
Fibonacci closure in Golang
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
n_1, n := -1, 1
return func() int {
tmp := n

Keybase proof

I hereby claim:

  • I am pedromg on github.
  • I am pedromg (https://keybase.io/pedromg) on keybase.
  • I have a public key ASAHu8RbaxCP59ycfkQTB4j1U0k8KcF7A2fmQXciodG-two

To claim this, I am signing this object: