forked from ground/ground
Closures in Ground
This commit is contained in:
27
tests/closure.grnd
Normal file
27
tests/closure.grnd
Normal file
@@ -0,0 +1,27 @@
|
||||
set &x 5
|
||||
|
||||
PAUSE
|
||||
|
||||
fun !dingle -function -int &a
|
||||
|
||||
PAUSE
|
||||
|
||||
fun !capture -int -int &b
|
||||
|
||||
PAUSE
|
||||
|
||||
add $a $b &tmp
|
||||
add $tmp $x &tmp
|
||||
return $tmp
|
||||
endfun
|
||||
|
||||
return $capture
|
||||
|
||||
endfun
|
||||
|
||||
call !dingle 3 &result
|
||||
|
||||
PAUSE
|
||||
|
||||
call !result 5 &y
|
||||
println $y
|
||||
Reference in New Issue
Block a user