Control Structures: (:for)

:for (iterators[.fieldlist]) {arg[.fieldlist]{code}}

Commentary Code Result
Commentary :for(1..3){'done'},, done done done
Commentary :for(1..3[.i]){i} %** $; Seq[I411R1C3T:P]:
[1]Num[S421R1C1:I]1
[2]Num[S447R1C1:I]2
[3]Num[S472R1C1:I]3
Commentary 'w1' 'w2' 'w3'=>list;
:for(list[.word]){"word is: "word$;};
word is: w1
word is: w2
word is: w3
Commentary #ns => @;3` =>accts;10=> ?;
:for(accts){10*->4?}=>sales;
  :for(accts sales[.a.s]){
     s\+ =>t; 'acct 'a
     ': sales: 's'; total:'t$;t }< =>gt;
'Grand Total: ' (gt\+) $;
acct 1: sales: 6 5 4 9; total:24
acct 2: sales: 10 10 2 8; total:30
acct 3: sales: 3 10 9 6; total:28
Grand Total: 82
Commentary 13#asc =>nl;
:for(10 20 30[.i]){
  :for(1 2 [.j]){
    'i='i'; j='j
    '; i+j='(i+j)nl %*
 }
}$;
i=10; j=1; i+j=11
i=10; j=2; i+j=12
i=20; j=1; i+j=21
i=20; j=2; i+j=22
i=30; j=1; i+j=31
i=30; j=2; i+j=32
Commentary 'john''mary''sue'=>n;
1000 2000 3000=>a;
:for(n a[.name.acct]){
   name ':' acct %*} ,,\ 
Result:
john:1000
mary:2000
sue:3000
Commentary 3` =>count;0> *->(count#)=>res;
:for(count[.i]){res@[.r]{
   i` =>[i]r;}};
res %**$;
Seq[I320R3C3T:P]:
[1]Num[I505R1C1:I]1
[2]Num[I642R1C2:I]1 2
[3]Num[I779R1C3:I]1 2 3
Commentary 1..8=>pressure;
:for(pressure[.gauge]){
  :if(gauge<=2){
    gauge " is low"$;:continue;};
  :if(gauge=4){
    gauge " is high"$;:continue;};
  :if(gauge=5){
    gauge " shut down!!!"$;:break;};
  :if(gauge=6){
    gauge " we're dead"$;:break;};
  gauge " is ok"$;}
1 is low
2 is low
3 is ok
4 is high
5 shut down!!!