talc/examples/closures2.talc

24 lines
248 B
Text
Raw Normal View History

2024-11-03 17:50:36 +00:00
#!/usr/bin/env talc
2024-10-31 21:20:20 +00:00
var i = 0;
var outer = \n -> do
var inner = \-> do
i = i + n
end
end
var by3 = outer(3)
var by5 = outer(5)
by3()
println(i) -- 3
by3()
println(i) -- 6
by5()
println(i) -- 11
by5()
println(i) -- 16
by3()
println(i) -- 19