dfinity / motoko-base

The Motoko base library
Apache License 2.0
483 stars 99 forks source link

experiment: use more tail recursion in List.mo #635

Open crusso opened 5 months ago

crusso commented 5 months ago

Remove potential for stack overflow from List.map, List.filter, List.mapFilter and List.split by using tail-recursive, not recursive, implementations. Also removes the potential for stack overflow from Deque.mo (which uses List.split.

Not necessarily for merging since this penalises performance for more reasonable small lists.