D-Programming-Language/phobos — pull request #1955 by monarchdodra (2014-02-21 21:55:18+00:00)
Title: Introduce fold to algorithm

This is a preliminary rough sketch to add a new "fold" to algorithm. It is designed as a replacement to reduce:
* UFCS-friendly args.
* More customizable behavior (foldl/foldr for left/right associativity) (seed: fold/fold1 for T.init/front)
* More seed customization (0, 1 or N seeds)

This is a *proof of concept* submission. I'd be most interested in reviewing the API/design first. If/when we decide the API is good, I'd be more than happy to nitpick away at the code.

Pinging @bearophile : I'm not sure if this is exactly what haskell does, but I think this design makes sense for D? but can you give me your opinion?