aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/list.gleam10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/list.gleam b/src/list.gleam
index dd8fb8a..288d971 100644
--- a/src/list.gleam
+++ b/src/list.gleam
@@ -7,6 +7,9 @@ pub enum Empty =
pub enum NotFound =
| NotFound
+pub enum LengthMismatch =
+ | LengthMismatch
+
// Using the Erlang C BIF implementation.
//
pub external fn length(List(a)) -> Int = "erlang" "length"
@@ -192,6 +195,13 @@ pub fn zip(l1, l2) {
}
}
+pub fn strict_zip(l1, l2) {
+ case length(l1) == length(l2) {
+ | True -> Ok(zip(l1, l2))
+ | False -> Error(LengthMismatch)
+ }
+}
+
pub fn intersperse(list, elem) {
case list {
| [] -> []