>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary

for.

    for.     T do. B end.
    for_xyz. T do. B end.

The`B` block is evaluated once for each item of the array`A` that results from evaluating the`T` block. In the`for_xyz.` form, the local name`xyz` is set to the value of an item on each evaluation and`xyz_index` is set to the index of the item.
`break.` goes to the end of the`for.` control structure, and`continue.` goes to the evaluation of`B` for the next item.

For example:

    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

    queens=: 3 : 0                solves the n queens problem
     z=.i.n,*n=.y.
     for. }.z do.
      b=. -. (i.n) e."1 ,. z +"1 _ ((-i.){:$z) */ _1 0 1
      z=. ((+/"1 b)#z),.(,b)#(*/$b)$i.n
     end.
    )

       queens 5
    0 2 4 1 3
    0 3 1 4 2
    1 3 0 2 4
    1 4 2 0 3
    2 0 3 1 4
    2 4 1 3 0
    3 0 2 4 1
    3 1 4 2 0
    4 1 3 0 2
    4 2 0 3 1

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary