2024-11-03 17:50:36 +00:00
|
|
|
#!/usr/bin/env talc
|
|
|
|
|
2024-10-31 21:20:20 +00:00
|
|
|
-- adapted from Crafting Interpreters 10.6
|
|
|
|
|
|
|
|
make_counter = \-> do
|
|
|
|
var i = 0
|
|
|
|
\-> do
|
|
|
|
i += 1
|
|
|
|
println(i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
var counter1 = make_counter()
|
|
|
|
counter1() -- 1
|
|
|
|
counter1() -- 2
|
|
|
|
counter1() -- 3
|
|
|
|
counter1() -- 4
|
|
|
|
var counter2 = make_counter()
|
|
|
|
counter2() -- 1
|
|
|
|
counter2() -- 2
|
|
|
|
counter1() -- 5
|
|
|
|
counter1() -- 6
|
|
|
|
counter2() -- 3
|