flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 189: Filter and transform list
Idiom # 189: Filter and transform list
See
programming-idioms.org
:
Code
y := (x.filter P).map T
What are effects?
Running Example
ex189 is x := 0.. # all non-negative integers P i32 -> bool := i -> i %% 3 # divisible by 3 T i32 -> String := i -> "{i}² = {i*i}" y := (x.filter P).map_sequence T # NYI: should be 'map', not 'map_sequence, see Fuzion #252' y.take 20 | e -> say e # alternatively, we can use 'infix &' instead of 'filter' y := (x & P).map_sequence T y.take 20 | e -> say e # NYI: This should be possible using pipe instead of 'map' # # y := x & P | T
What are effects?
next: NYI: Idiom # 190: Call an external C function