while. and whilst. 控制結構
are used in 明確 定義(:).while. T do. B end. whilst. T do. B end.last 句子 executed in T block is tested for a non-zero value in its leading 原子. If true, B block is executed. T block is n retested,與so on, continuing until T block tests false. (An empty T block result or an omitted T block tests true.) whilst. differs from while. only in that it skips test first time. break. goes to end of while or whilst. 控制結構 and continue. goes to top. |
exp =: 4 : 0 Exponentiation by repeated squaring z=.1 a=.x. n=.y. while. n do. if. 2|n do. z=.z*a end. a=.*:a n=.<.-:n end. z ) 3 exp 7 2187 3 ^ 7 2187 1.1 exp 0 1 2x exp 128 340282366920938463463374607431768211456