aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam/list.gleam6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam
index e782b45..83870b4 100644
--- a/src/gleam/list.gleam
+++ b/src/gleam/list.gleam
@@ -1913,8 +1913,10 @@ fn do_window(acc: List(List(a)), l: List(a), n: Int) -> List(List(a)) {
/// ```
///
pub fn window(l: List(a), by n: Int) -> List(List(a)) {
- do_window([], l, n)
- |> reverse
+ case n <= 0 {
+ True -> []
+ False -> do_window([], l, n) |> reverse
+ }
}
/// Returns a list of tuples containing two contiguous elements.