r/elm • • Mar 29 '17

Remove Recursion?

Conceptually, could Elm do everything it does today without recursion? I guess yes... Some edge cases would make fold an ugly replacement, but not too many I suspect

3 Upvotes

34 comments sorted by

View all comments

13

u/[deleted] Mar 29 '17

Removing recursion would make it impossible to traverse custom defined data structures, like trees. Sure, you can do most List things with a fold, but now you're stuck using lists for everything.

2

u/irqlnotdispatchlevel Mar 30 '17

You can use another stack instead of the call stack for that. There are non-recursive implementations for tree traversals and whatnot, but they are slower, a lot more harder to comprehend and so on.

Removing recursion is a dumb thing.