fuzion-lang.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.0 j := ij.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.0 j := ij.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" t tuple => say "$x found at ({t.0},{t.1})"
What are effects?
last changed: 2024-07-01
next: Idiom # 21: Swap values