for. 控制結構 is used in 明確 定義
(:).for. T do. B end. for_xyz. T do. B end.B block is evaluated once for each item of 陣列 A that results from evaluating T block. In for_xyz. form, local name xyz is set to value of an item on each evaluation and xyz_索引 is set to 索引 of item. break. goes to end of for. 控制結構, and continue. goes to evaluation of B for 下個 item. |
f0=: 3 : 0
s=. 0
for. i. y. do. s=.>:s end.
)
f1=: 3 : 0
s=.0
for_j. i.y. do.
if. 2|j do. continue. end.
s=.j+s
end.
)
comb=: 4 : 0 All size x. combinations of i.y.
z=.1 0$k=.i.#c=.1,~(y.-x.)$0
for. i.x. do. z=.;k,.&.>(-c=.+/\.c){.&.><1+z end.
)
(f0 = ])"0 ?5$100
1 1 1 1 1
(f1 = 2&!@>.&.-:)"0 ?5$100
1 1 1 1 1
3 comb 5
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4