Convenience functions for working with tuples.
Tuple functions for 3-tuplesExtract the second value from a 3-tuple.
second ( 3, 4, 5 ) --> 4
second ( "John", "H.", "Doe" ) --> "H."Extract the third value from a 3-tuple.
third ( 3, 4, 5 ) --> 5
third ( "John", "H.", "Doe" ) --> "Doe"Transform the first value in a 3-tuple.
mapFirst String.reverse ( "stressed", 16, 1 ) --> ("desserts", 16, 1)
mapFirst String.length ( "stressed", 16, 1 ) --> (8, 16, 1)Transform the second value in a 3-tuple.
mapSecond sqrt ( "stressed", 16, 1 ) --> ("stressed", 4, 1)
mapSecond negate ( "stressed", 16, 1 ) --> ("stressed", -16, 1)Transform the second value in a 3-tuple.
mapThird (List.repeat 2) ( "stressed", 16, 1 ) --> ("stressed", 16, [1, 1])
mapThird String.fromInt ( "stressed", 16, 1 ) --> ("stressed", 16, "1")Transform all three parts of a 3-tuple.
mapAllThree String.reverse sqrt List.length ( "stressed", 16, [] ) --> ("desserts", 4, 0)
mapAllThree String.length negate List.isEmpty ( "stressed", 16, [] ) --> (8, -16, True)Create a 2-tuple.
{ foo = [1, 2], bar = Nothing }
|> pairTo Cmd.none
--> ({ foo = [1, 2], bar = Nothing }, Cmd.none)Create a 2-tuple.
double 0 --> (0, 0)Create a 3-tuple.
triple 0 --> (0, 0, 0)Swap the values in a tuple.
swap ( '1', "1" ) --> ("1", '1')Reverse values in a 3-tuple.
reverse ( 1, 2, 3 ) --> (3, 2, 1)Rotate values in 3-tuple to the left.
rotateLeft ( 1, 2, 3 ) --> (2, 3, 1)Rotate values in 3-tuple to the right.
rotateRight ( 1, 2, 3 ) --> (3, 1, 2)Swap first two values in a 3-tuple.
swapFirst ( 1, 2, 3 ) --> (2, 1, 3)Swap last two values in a 3-tuple.
swapLast ( 1, 2, 3 ) --> (1, 3, 2)Apply each value in a 2-tuple to a function that takes at least 2 arguments.
uncurry2 List.repeat ( 3, 'a' ) --> ['a', 'a', 'a']Apply each value in a 3-tuple to a function that takes at least 3 arguments.
type alias Person =
{ name : String
, age : Int
, hobbies : List String
}
uncurry3 Person ("John Doe", 34, ["Hockey"])
--> { name = "John Doe", age = 34, hobbies = [ "Hockey" ] }
Extract the first value from a 3-tuple.