▲ | munchler 5 days ago | |||||||
I would hope that most standard libraries are optimized to avoid this sort of waste as much as possible. In F#, for example, I know that the standard `map` and `fold` are implemented imperatively for maximum performance. | ||||||||
▲ | xdavidliu 4 days ago | parent [-] | |||||||
I don't know F#, but even if that were true, I'm guessing you need a list of the data in memory in the first place in order to fold or map over. That's still a disadvantage, since with tail recursion you don't, and thus it takes O(1) memory total. | ||||||||
|