diff options
| author | 2025-06-16 11:51:46 +0200 | |
|---|---|---|
| committer | 2025-06-16 11:51:46 +0200 | |
| commit | 2ae76e402eac4b451ce58ce41352def8ff2dffb9 (patch) | |
| tree | 279eb649120701ab11b8c027709f0240038f78ae /test.pez | |
| parent | 3967fccab7a41f8218b7ba589eee470d7ab4972a (diff) | |
change lambda syntax {[a] x} -> $[a]{x}
Diffstat (limited to 'test.pez')
| -rw-r--r-- | test.pez | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -1,19 +1,19 @@ -@Box: {[value] +@Box: $[value] { dilambda[ - { value }, - {[new] value = new } + ${ value }, + $[new] { value = new } ] } -@Array2d: {[w, h] +@Array2d: $[w, h] { @data: array#new[w * h, 0] dilambda[ - {[x, y] data[x + (y * w)] }, - {[x, y, new] data[x + (y * w)] = new } + $[x, y] { data[x + (y * w)] }, + $[x, y, new] { data[x + (y * w)] = new } ] } -@print: {[x] printf["x -> %a\n", x] } +@print: $[x] { printf["x -> %a\n", x] } @x = Box[-7] x[] *= 2 print[x[]] @@ -27,7 +27,7 @@ FOR [@x: 0][< 10][+ 1] printf["%a == %a\n", m[3,7], 3^7] -@add: {[*] +@add: $[*] { @acc = 0 FOR [@i: 0][< SEL$][+ 1] acc += SEL[i] @@ -36,13 +36,11 @@ printf["%a == %a\n", m[3,7], 3^7] printf["4+1+3: %a\n", add[4,1,3]] -@gather: {[*] - SEL[*] -} +@gather: $[*] { SEL[*] } printf["test %a\n", gather[-1, (), 'x]] -@map: {[f, xs] +@map: $[f, xs] { @ys: array#new[xs.len] FOR [@i: 0][< xs.len][+ 1] ys[i] = f[xs[i]] @@ -51,7 +49,7 @@ printf["test %a\n", gather[-1, (), 'x]] printf["maps %a\n", map["abcd", #[1,2,0]]] -@inspect: {[m] +@inspect: $[m] { printf["%a\n", m] } @@ -60,6 +58,6 @@ r[0]=r printf["r: "] inspect[r] printf["r.a -> %a\n", r[0].a] -{ +${ inspect [#{0 3,"a" 3}] }[] |