Version française
Home     About     Download     Resources     Contact us    
Browse thread
The Map and Fold
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: lloydmoore <lloyd@e...>
Subject: The Map and Fold
In reply to the relationship between map and fold, The fold difference
is that only a single entity is returned (the accumulator) as opposed
to, if you like, a place for each original array/list/vector member.
Fold is indeed an extended specialized version of map because it has to
perform both functions... iterate over the elements and use them as
function arguments but it then goes one step further and accumulates the
results as it iterates.

Using STL, this would be the difference between mapping a X.t into b X.t
and stopping there, or going the extra step and summising your new set
of results 'on the fly' as it were.

Hope this makes sense :D
http://www.encantado.net