[erlang-questions] foldl vs foldr and ++
Wed May 9 21:14:18 CEST 2012
> My understanding is that foldl is preferred over foldr because it is tail
> recursive. I was also to understand that putting the accumulator on the
> left-hand-side of the ++ operation is super bad.
According to Erlang and OTP in Action, the cost of ++ is specified by the
left side. ++ copies the items on the left side on top of the right side
which explains the performance difference. If the order does not matter,
always put the smaller list on the left side.
Founder and Lead Developer
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions