1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
@Box: {[value]
dilambda[
{ value },
{[new] value = new }
]
}
@Array2d: {[w, h]
@data: array#fill[w * h, 0]
dilambda[
{[x, y] data[x + (y * w)] },
{[x, y, new] data[x + (y * w)] = new }
]
}
@print: {[x] printf["x -> %a\n", x] }
@x = Box[-7]
x[] *= 2
print[x[]]
x[] = 'abcdef
print[x[]]
@m: Array2d[10, 10]
FOR [@x: 0][< 10][+ 1]
FOR [@y: 0][< 10][+ 1]
m[x, y] = x ^ y
printf["%a == %a\n", m[3,7], 3^7]
@add: {[*]
@acc = 0
FOR [@i: 0][< SEL$][+ 1]
acc += SEL[i]
acc
}
printf["4+1+3: %a\n", add[4,1,3]]
@gather: {[*]
SEL[*]
}
printf["test %a\n", gather[-1, (), 'x]]
@map: {[f, xs]
@ys: array#filled[xs.len, ()]
FOR [@i: 0][< xs.len][+ 1]
ys[i] = f[xs[i]]
ys
}
printf["%a\n", map["abcd", #[1,2,0]]]
|