Created
August 19, 2011 10:16
-
-
Save anonymous/1156522 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" | |
| type ( | |
| Test1 func() Test2 | |
| Test2 func() Test1 | |
| ) | |
| func (t Test1) Next() Test2{ | |
| return t() | |
| } | |
| func (t Test2) Next() Test1{ | |
| return t() | |
| } | |
| var ( | |
| Series Test1 = func() (t1 Test2) { | |
| b, res := 1, 1. | |
| return Test2(func() (t Test1) { | |
| b += 1 | |
| res -= 1.0/float64(b) | |
| fmt.Println(res) | |
| return Test1(func() (t Test2) { | |
| b += 1 | |
| res += 1.0/float64(b) | |
| fmt.Println(res) | |
| return t1 | |
| }) | |
| }) | |
| } | |
| ) | |
| //1-1/2+1/3-1/4... | |
| func main() { | |
| Series().Next().Next().Next().Next().Next().Next().Next() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment