diff options
author | Peter <peterhsaxton@gmail.com> | 2020-08-14 08:52:33 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2020-08-14 11:27:21 +0100 |
commit | 4943602689657203ba763d4f7107f2fd8048c864 (patch) | |
tree | 64ef6348e954cf233345d2add8bf66c43d6ec569 | |
parent | fdf7145a92a4be1e9780372b8de5c4770ee06d33 (diff) | |
download | gleam_stdlib-4943602689657203ba763d4f7107f2fd8048c864.tar.gz gleam_stdlib-4943602689657203ba763d4f7107f2fd8048c864.zip |
add docs
-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, [], []) } |