While: Difference between revisions

From The K Language Wiki
Content added Content deleted
("Add category")
("Add all appropriate categories to each verb")
 
Line 18: Line 18:


[[Category:Adverbs]]
[[Category:Adverbs]]
[[Category:Primitives]]

Latest revision as of 03:17, 9 July 2022

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)