Skip to content

Instantly share code, notes, and snippets.

Created August 19, 2011 10:16
Show Gist options
  • Save anonymous/1156522 to your computer and use it in GitHub Desktop.
Save anonymous/1156522 to your computer and use it in GitHub Desktop.
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