elm-community / list-extra

Convenience functions for working with List.
http://package.elm-lang.org/packages/elm-community/list-extra/latest
MIT License
135 stars 58 forks source link

Make remove tail-call optimized #159

Closed jfmengels closed 2 years ago

jfmengels commented 2 years ago

This makes remove tail-call optimized, meaning it will not blow up the stack when working on lists that are too large.

|This also improves performance:](https://github.com/jfmengels/elm-benchmarks/blob/master/src/ImprovingPerformance/ListExtra/Remove.elm)

Screenshot from 2021-12-18 10-50-05

I also special-cased the case where the element is not found so that we don't unnecessarily recreate the entire list from the accumulator.

I also added tests for remove and applied elm-format (seems like tests weren't properly formatted).

Chadtech commented 2 years ago

Awesome work! Thanks @jfmengels