if.

if. 控制結構 is used in 明確 定義 (:).
if. T do. B end.
if. T do. B else. B1 end.
if. T do. B elseif. T1 do. elseif. T2 do. B2 end.
last 句子 executed in a T block is tested for a non-zero value in its leading 原子, determining wher B block after do. or rest of 句子 is executed. An empty T block result or an omitted T block tests true.

See also select. 控制結構.
 

例如:
plus=: 4 : 0                  Addition on 非負整數s
 if. y. do. >: x. plus <: y. else. x. end.
)

   plus"0/~ i.5
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8

sel=: 1 : 'x. # ['

q排序=: 3 : 0
 if. 1 >: #y. do. y.
 else. 
  (q排序y.<sel e),(y.=sel e),q排序y.>sel e=.y.{~?#y.
 end.
)

   q排序15 2 9 10 4 0 13 13 18 7 
0 2 4 7 9 10 13 13 15 18

test=: 3 : 0
 if.     0<y. do. 'positive'
 elseif. 0>y. do. 'negative'
 elseif.      do. 'zero'
 end.
)

   test&.> 5 _2.71828 0
+--------+--------+----+
|positive|negative|zero|
+--------+--------+----+
    
   test&.> '' ; 0 1 _2 ; _3 9
+--------+----+--------+
|positive|zero|negative|
+--------+----+--------+

下個前個字彙索引主選單