caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* map and fold
@ 2006-12-22 11:18 skaller
  2006-12-22 12:12 ` [Caml-list] " Florian Hars
  2006-12-23 23:54 ` Andrej Bauer
  0 siblings, 2 replies; 6+ messages in thread
From: skaller @ 2006-12-22 11:18 UTC (permalink / raw)
  To: caml-list

What is the relationship between map and fold?

It seems like if you have a X.fold plus an constructor
which adds an element to an existing container Y.t
you can define a kind of map which copies elements of
'a X.t into 'b T.t given an element map f: 'a -> 'b.

In STL the algorithm accumulate can do this, given
a start and end iterator for the input container,
and an insert iterator for the output container.

Anyhow it 'feels' like the fold is a container destructor,
and the constructor is a kind of 'dual' of fold. Map is then
just a combination of the fold with a special case of
the constructor function.. hmm. Any hint what the formal
symmetry is here?


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-12-24 11:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-22 11:18 map and fold skaller
2006-12-22 12:12 ` [Caml-list] " Florian Hars
2006-12-23 23:54 ` Andrej Bauer
2006-12-24  3:26   ` skaller
2006-12-24  3:42   ` skaller
2006-12-24 11:00     ` Tom

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).