MakeClosure, FreeVar; FuncAddCtx; aggregateAlloc

This commit is contained in:
xushiwei
2024-05-05 17:39:17 +08:00
parent 3c33a1d05e
commit d7df46d578
9 changed files with 175 additions and 46 deletions

View File

@@ -13,8 +13,16 @@ func genInts(n int, gen func() c.Int) []c.Int {
}
func main() {
initVal := c.Int(1)
a := genInts(5, c.Rand)
for _, v := range a {
c.Printf(c.Str("%d\n"), v)
}
b := genInts(5, func() c.Int {
initVal *= 2
return initVal
})
for _, v := range b {
c.Printf(c.Str("%d\n"), v)
}
}