Created
December 18, 2015 17:51
-
-
Save caelifer/0ce1bc34323b3cfa2a6b to your computer and use it in GitHub Desktop.
This file contains 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 F1 func(int) int | |
type F2 func(int, int) int | |
func apply(f F2, n int) F1 { | |
return func(x int) int { | |
return f(n, x) | |
} | |
} | |
func sum(a, b int) int { | |
return a + b | |
} | |
func main() { | |
d := 0 | |
f := apply(sum, 5) | |
for i := 0; i < 1000000000; i++ { | |
d = f(i) | |
} | |
fmt.Println(d) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Live code - http://play.golang.org/p/6bHi_fv5K1