gleam-lang / stdlib

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

Iterator try_fold will exceed call stack size in javascript target #688

Closed pendletong closed 3 weeks ago

pendletong commented 2 months ago

Running the following on the Gleam language tour results in 'too much recursion' error

`import gleam/iterator

pub fn main() { iterator.range(1,6000) |> iterator.try_fold(0, fn(acc, i) { Ok(acc+i) }) } `

Changing to use list.range and list.try_fold works, presumably because list.try_fold is tail recursive unlike iterator.try_fold

sharno commented 3 weeks ago

This seems to be fixed

lpil commented 3 weeks ago

Thank you