diff options
| author | 2022-10-09 11:43:26 +0200 | |
|---|---|---|
| committer | 2022-10-09 11:43:26 +0200 | |
| commit | ed34de7ff26e0077a8d00794e469f273ebdb5c4a (patch) | |
| tree | 34b7a8f1af24f932cfeffd9e6792e4ff31adb439 /test.pez | |
| parent | f04e8718a3aae2a03a5df4dfff7c773f3cf19a99 (diff) | |
closures
Diffstat (limited to 'test.pez')
| -rw-r--r-- | test.pez | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -1,16 +1,12 @@ -~fib= {[x] - x < 2 ? x : fib[x - 1] + fib[x - 2] -} +@print: {[x] printf["%a\n", x]} -printf["fib[10] = %a\n", fib[10]] +@Box: {[value] + #[{value}, + {[new] value = new}] + } -@sum: {[xs] @a = 0 - @n: xs.length - FOR [@i: 0][< n][+ 1] ( - a += xs[i] - ) - a -} -(@l: #[1,5,-2,7] - printf["sum[%a] = %a\n", l, sum[l]]) +@x = Box[-7] +print[x[0][]] +x[1]['awesome] +print[x[0][]] |