Holumbus-Searchengine-1.2.3: A search and indexing engine.

Stabilityexperimental
MaintainerUwe Schmidt (uwe@fh-wedel.de)
Safe HaskellNone

Control.Sequential.MapFoldBinary

Description

A map-fold function for interleaved map and fold. The elements of a list are processed like in a binary tree.

Synopsis

Documentation

mapFoldBinary :: (a -> b) -> (b -> b -> b) -> [a] -> bSource

Pure version of binary map fold

mapFoldBinary id (+) [1..8] adds the elements of a list in the following order: (((1+2)+(3+4))+((5+6)+(7+8)))

mapFoldBinaryM :: Monad m => (a -> m b) -> (b -> b -> m b) -> [a] -> m bSource

Monadic version of a binary map fold

The elements of a list are mapped and folded in the same way as in the pure version. The map and fold operations are interleaved. In the above example the expressions are evaluated from left to right, folding is performed, as early as possible.