flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 20: Return two values
Idiom # 20: Return two values
See
programming-idioms.org
:
Code
search(m array2 i32, x i32) => for # (i,j) in m.index_pairs // NYI: destructure syntax sugar still missing ij in m.index_pairs i := ij.values.0 j := ij.values.1 until m[i,j] = x option (i, j) else nil
What are effects?
Running Example
ex20 is search(m array2 i32, x i32) => for # (i,j) in m.index_pairs // NYI: destructure syntax sugar still missing ij in m.index_pairs i := ij.values.0 j := ij.values.1 until m[i,j] = x option (i, j) else nil data := array2 10 10 i,j->i*j (1..100 : 4) | x -> match search data x nil => say "$x not found" # (i, j) => say "$x found at ($i,$j)" // NYI: destructure in match not supported yet t tuple => (i, j) := t say "$x found at ($i,$j)"
What are effects?
next: Idiom # 21: Swap values