5
$\begingroup$

Foldl and folr are 2 very important functions for FP and Haskell, but I have never heard much about the unsided fold:

fold f [a,b,c,d] = (f (f a b) (f c d))

That is, a fold that operates on binary associative functions (so the order of application doesn't matter). If I recall correctly, this is very common in databases as it can be parallelized. So, about it, I ask:

  1. Is it, like foldr, universal?
  2. Like foldr, can you define every important function using it?
  3. Is there a fusion rule for it, similar to those for foldr/build and unfoldr/destroy?
  4. Why is it barely mentioned?
  5. Any consideration worth mentioning?
$\endgroup$
  • $\begingroup$ Nearly cross-posted: stackoverflow.com/questions/20986286/… $\endgroup$ – frafl Jan 9 '14 at 23:10
  • $\begingroup$ Not really, I'm expecting different answers from those different contexts (SO = how to implement foldl with fold, here = general properties of the unsided fold). $\endgroup$ – Viclib Jan 10 '14 at 4:01
  • $\begingroup$ Perhaps you want to cross-post it at cstheory (unless you already have). $\endgroup$ – Yuval Filmus Jan 23 '14 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.