Skip to content

Instantly share code, notes, and snippets.

@caelifer
Created December 18, 2015 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caelifer/0ce1bc34323b3cfa2a6b to your computer and use it in GitHub Desktop.
Save caelifer/0ce1bc34323b3cfa2a6b to your computer and use it in GitHub Desktop.
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)
}
@caelifer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment