while

From The K Language Wiki
Revision as of 03:17, 9 July 2022 by Promovicz (talk | contribs) ("Add all appropriate categories to each verb")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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)