fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 247: Filter list in-place
Idiom # 247: Filter list in-place
See
programming-idioms.org
:
Code
# Fuzion lists are immutable, but Fuzion has some mutable data # types as well. One is 'mutate.array' that provides a mutable array. # Using 'mutate.array (option T)', we can remove elements by setting # them to 'nil': # for i in x.indices do if !(p x[i].get) x[i] := nil
What are effects?
Running Example
ex247 is mi : mutate is mi.instate_self ()-> x := (mutate.array (option i64)).new mi 100 nil for i in x.indices do x[i] := i p i64 -> bool => i -> i %% 6 for i in x.indices do if !(p x[i].get) x[i] := nil say x
What are effects?
last changed: 2024-07-01
next: Idiom # 248: Construct a 64-bit floating-point value