Source file
test/abi/fibish_closure.go
1
2
3
4
5
6
7
8
9 package main
10
11 import "fmt"
12
13
14
15 type MagicLastTypeNameForTestingRegisterABI func(int, MagicLastTypeNameForTestingRegisterABI) (int, int)
16
17
18 func f(x int, unused MagicLastTypeNameForTestingRegisterABI) (int, int) {
19
20 if x < 3 {
21 return 0, x
22 }
23
24 a, b := f(x-2, unused)
25 c, d := f(x-1, unused)
26 return a + d, b + c
27 }
28
29 func main() {
30 x := 40
31 a, b := f(x, f)
32 fmt.Printf("f(%d)=%d,%d\n", x, a, b)
33 }
34
View as plain text