fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 196: Pass a sub-array
Idiom # 196: Pass a sub-array
See
programming-idioms.org
:
Code
Code input
# fuzion arrays are immutable, we need to use mutate.array instead n := 20 m := 13 foo (E type : mutate, a container.Mutable_Array i32, i i32) ! E => a[i] := 42 mi : mutate is mi.instate_self ()-> a := (mi.array i32).new mi n 0 a.indices.for_each (i -> a[i] := i) (1..m : 2).for_each (i -> foo a i)
What are effects?
Running Example
Code input
ex196 is n i64 := 20 m i64 := 13 foo (E type : mutate, a container.Mutable_Array i64 E, i i64) ! E => a[i] := 42 mi : mutate is mi.instate_self ()-> a := (mi.array i64).new mi n 0 a.indices.for_each (i -> a[i] := i) say a ((i64 1)..m : 2).for_each (i -> foo a i) say a
What are effects?
last changed: 2025-05-13
next: Idiom # 197: Get a list of lines from a file