flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 143: Iterate alternatively over two lists
Idiom # 143: Iterate alternatively over two lists
See
programming-idioms.org
:
Code
iterate_alternatively(T type, a, b Sequence T, f T -> unit) unit is match a.as_list nil => b | f c Cons => f c.head; iterate_alternatively b c.tail f
What are effects?
Running Example
ex143 is iterate_alternatively(T type, a, b Sequence T, f T -> unit) unit is match a.as_list nil => b | f c Cons => f c.head; iterate_alternatively b c.tail f items1 := [0, 2, 4] items2 := [1, 3] iterate_alternatively items1 items2 (x -> say x)
What are effects?
next: Idiom # 144: Check if file exists