zipnotic
Functions
pub fn strict_zip_2(
list: List(a),
other: List(b),
) -> Result(List(#(a, b)), Nil)
Zips two lists into a result. If the lists are all equal in length, a list
of tuples is returned within Ok
. If the lists are not the same length,
Error(Nil)
is returned.
strict_zip_2([1], ["a"])
// -> Ok([#(1, "a")])
strict_zip_2([1, 2], ["a"])
// -> Error(Nil)
pub fn strict_zip_3(
list: List(a),
other_1: List(b),
other_2: List(c),
) -> Result(List(#(a, b, c)), Nil)
Zips three lists into a result. If the lists are all equal in length, a list
of tuples is returned within Ok
. If the lists are not the same length,
Error(Nil)
is returned.
strict_zip_3([1], ["a"], [1.0])
// -> Ok([#(1, "a", 1.0)])
strict_zip_3([1, 2], ["a"], [1.0])
// -> Error(Nil)
pub fn strict_zip_4(
list: List(a),
other_1: List(b),
other_2: List(c),
other_3: List(d),
) -> Result(List(#(a, b, c, d)), Nil)
Zips four lists into a result. If the lists are all equal in length, a list
of tuples is returned within Ok
. If the lists are not the same length,
Error(Nil)
is returned.
strict_zip_4([1], ["a"], [1.0], [True])
// -> Ok([#(1, "a", 1.0, True)])
strict_zip_4([1, 2], ["a"], [1.0], [True])
// -> Error(Nil)
pub fn unzip_2(input: List(#(a, b))) -> #(List(a), List(b))
Unzips a list of tuples into two separate lists.
unzip_2([#(1, "a"), #(2, "b")])
// -> #([1, 2], ["a", "b"])
pub fn unzip_3(
input: List(#(a, b, c)),
) -> #(List(a), List(b), List(c))
Unzips a list of tuples into three separate lists.
unzip_3([#(1, "a", 1.0), #(2, "b", 2.0)])
// -> #([1, 2], ["a", "b"], [1.0, 2.0])
pub fn unzip_4(
input: List(#(a, b, c, d)),
) -> #(List(a), List(b), List(c), List(d))
Unzips a list of tuples into four separate lists.
unzip_4([#(1, "a", 1.0, True), #(2, "b", 2.0, False)])
// -> #([1, 2], ["a", "b"], [1.0, 2.0], [True, False])
pub fn unzip_longest_2(
input: List(#(Option(a), Option(b))),
) -> #(List(a), List(b))
Unzips a list of tuples containing optional values into two separate lists.
unzip_longest_2([#(Some(1), Some("a")), #(None, Some("b"))])
// -> #([1], ["a", "b"])
pub fn unzip_longest_3(
input: List(#(Option(a), Option(b), Option(c))),
) -> #(List(a), List(b), List(c))
Unzips a list of tuples containing optional values into three separate lists.
unzip_longest_3([#(Some(1), Some("a"), Some(True)), #(None, Some("b"), None)])
// -> #([1], ["a", "b"], [True])
pub fn unzip_longest_4(
input: List(#(Option(a), Option(b), Option(c), Option(d))),
) -> #(List(a), List(b), List(c), List(d))
Unzips a list of tuples containing optional values into four separate lists.
unzip_longest_4([#(Some(1), Some("a"), Some(1.0), Some(True)), #(None, Some("b"), None, Some(False))])
// -> #([1], ["a", "b"], [1.0], [True, False])
pub fn zip_2(list: List(a), other: List(b)) -> List(#(a, b))
Zips two lists into tuples of values. Zipping ends when the shortest list is exhausted.
zip_2([1, 2], ["a"])
// -> [#(1, "a")]
pub fn zip_3(
list: List(a),
other_1: List(b),
other_2: List(c),
) -> List(#(a, b, c))
Zips three lists into tuples of values. Zipping ends when the shortest list is exhausted.
zip_3([1], ["a", "b"], [1.0, 1.1])
// -> [#(1, "a", 1.0)]
pub fn zip_4(
list: List(a),
other_1: List(b),
other_2: List(c),
other_3: List(d),
) -> List(#(a, b, c, d))
Zips four lists into tuples of values. Zipping ends when the shortest list is exhausted.
zip_4([1], ["a", "b"], [1.0], [True, False])
// -> [#(1, "a", 1.0, True)]
pub fn zip_longest_2(
list: List(a),
other: List(b),
) -> List(#(Option(a), Option(b)))
Zips two lists into tuples containing optional values. Zipping ends when all lists are exhausted.
zip_longest_2([1], ["a", "b"])
// -> [#(Some(1), Some("a")), #(None, Some("b"))]
pub fn zip_longest_3(
list: List(a),
other_1: List(b),
other_2: List(c),
) -> List(#(Option(a), Option(b), Option(c)))
Zips three lists into tuples containing optional values. Zipping ends when all lists are exhausted.
zip_longest_3([1], ["a", "b"], [True])
// -> [#(Some(1), Some("a"), Some(True)), #(None, Some("b"), None)]
pub fn zip_longest_4(
list: List(a),
other_1: List(b),
other_2: List(c),
other_3: List(d),
) -> List(#(Option(a), Option(b), Option(c), Option(d)))
Zips four lists into tuples containing optional values. Zipping ends when all lists are exhausted.
zip_longest_4([1], ["a", "b"], [1.0], [True, False])
// -> [#(Some(1), Some("a"), Some(1.0), Some(True)), #(None, Some("b"), None, Some(False))]