Last active
November 10, 2018 10:06
-
-
Save williamlsh/78a739ae44b75c38cd24edc1fc421ebb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
f := fibonacci() | |
fmt.Println(f()) | |
} | |
func fibonacci() func()int { | |
pre, cur := 0, 1 | |
return func() int { | |
pre, cur = cur, pre+cur | |
return cur | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment