diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/gleam/list.gleam | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e0a52..d9d73a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ `of`. - The `dynamic` module gains the `any` function. - The `bit_builder` module gains the `from_string` function. -- The `list` module gains the `key_set` function. +- The `list` module gains the `key_set` and `unzip` function. - The `function` module gains the `rescue` function. ## v0.10.1 - 2020-07-01 diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index c82db2e..456310e 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -630,6 +630,16 @@ fn do_unzip(input, xs, ys) { } } +/// Takes a single list of 2 item tuples and returns two lists. +/// +/// ## Examples +/// +/// > unzip([tuple(1, 2), tuple(3, 4)]) +/// tuple([1, 3], [2, 4]) +/// +/// > unzip([]) +/// tuple([], []) +/// pub fn unzip(input: List(tuple(a, b))) -> tuple(List(a), List(b)) { do_unzip(input, [], []) } |