Standard library referenceModules
std/pair
Functions for tuples of two parts, (a, b).
new
Makes a pair.
new = <A, B>(first : A, second : B) -> (A, B) { (first, second) } first
The first part of a pair.
first = <A, B>(pair : (A, B)) -> A { pair.0 } second
The second part of a pair.
second = <A, B>(pair : (A, B)) -> B { pair.1 } swap
The pair with its parts the other way round.
pair.swap((1, "a")) // ("a", 1) swap = <A, B>(pair : (A, B)) -> (B, A) { map_first
Changes the first part of a pair with a function.
map_first = <A, B, C, N>(of : (A, B), with : (A) <- N -> C) -> (C, B) { map_second
Changes the second part of a pair with a function.
map_second = <A, B, C, N>(of : (A, B), with : (B) <- N -> C) -> (A, C) {