gleam-lang / stdlib

🎁 Gleam's standard library
https://hexdocs.pm/gleam_stdlib/
Apache License 2.0
466 stars 168 forks source link

`list.window` going into infinite recursion when `n` is 0 #612

Closed GioeleBucci closed 4 months ago

GioeleBucci commented 4 months ago

As per title, I noticed that the list.window function goes into an infinite loop if 0 is passed as second argument:

list.window([1, 2, 3], -1)    // []

list.window([1, 2, 3], 0)    // infinite loop!

Since it defaults to returning an empty list when n is negative, i thought the same approach could be used for 0 as well.

lpil commented 4 months ago

Thank you