imantc at gmail.com
Wed Dec 28 22:14:18 UTC 2016
thank you Tony and Yitzchak.
I may understand it one day ;)
it is important to understand it alright. I remember spending half a day
over unexpected (for me) results of recursive functions that contained
folds. In the end I settled for TChan - a queue with predictable behaviour
(my view of it - not necessarily correct).
Yitzchak, how about this:
Prelude Control.Applicative> *foldl* (<|>) Nothing [Just 1, Nothing, Just
Prelude Control.Applicative> *foldr* (<|>) Nothing [Just 1, Nothing, Just
? I guess this is due to the nature of (<|>), no?
Anyway, I'd use asum instead of fold_ for Alternatives.
for non-Alternative cases, Erlang analogy seems to be a useful rule of
thumb for foldl & foldr over shorter lists .
After all, what matters most is what results to expect. *foldl* and *foldr*
may yield different results for the same list & similar processing fn (save
for different arg order).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners