>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary

select.

select. T
 case.  T0 do. B0
 case.  T1 do. B1
 fcase. T2 do. B2
 case.  T3 do. B3
end.
The result R of T is compared to the elements of the result Ri of Ti , and the Bi block of the first case. or fcase. with a match is evaluated. Evaluation of the select. control structure then terminates for a case. , or continues with the next B(i+1) block for an fcase. (and further continues if it is an fcase.).

The comparison is R e.&boxifopen Ri where boxifopen=:<^:(L.=0:) , and a case with an omitted Ti is considered to match.
 

For example:
f0=: 3 : 0
 select. y
  case. 1;2 do. 'one two'
  case. 3   do. 'three'
  case. 4;5 do. 'four five'
  case. 6   do. 666
 end.
)

   f0&.> 1 2 3 4 5 6
+-------+-------+-----+---------+---------+---+
|one two|one two|three|four five|four five|666|
+-------+-------+-----+---------+---------+---+

   (i.0 0) -: f0 7
1

f1=: 3 : 0
 select. y
  case. 'a' do. i.1
  case. 'b' do. i.2
  case.     do. i.3
 end.
)

   f1&.> 'a' ; ('a';'b') ; 'b' ; 'x'
+-+-+---+-----+
|0|0|0 1|0 1 2|
+-+-+---+-----+

f2=: 3 : 0
 t=. ''
 select. y
  case.  1 do. t=.t,'one '
  fcase. 2 do. t=.t,'two '
  case.  3 do. t=.t,'three '
  fcase. 4 do. t=.t,'four '
 end.
)

   f2 1
one 

   f2 2
two three 

   f2 3
three 

   f2 4
four 

   '' -: f2 5
1


>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary