caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* The Map and Fold
@ 2006-12-23 15:48 lloydmoore
  0 siblings, 0 replies; only message in thread
From: lloydmoore @ 2006-12-23 15:48 UTC (permalink / raw)
  To: caml-list

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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-12-23 14:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-23 15:48 The Map and Fold lloydmoore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).