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