while

From The K Language Wiki
(Redirected from Scan-while)
While
g f/y
g f\y

while and scan-while are adverbs that apply a monadic function to a given noun y as long as the condition in g returns a truthy value when applied to y.

while(/) produces a single value, the final value.

Scan-while(\) produces a list of all intermediate values.

 {6>#x}{x,2*x}/2 3
2 3 4 6 4 6 8 12

 {6>#x}{x,2*x}\2 3
(2 3
 2 3 4 6
 2 3 4 6 4 6 8 12)