caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: caml-list@yquem.inria.fr
Subject: map and fold
Date: Fri, 22 Dec 2006 22:18:06 +1100	[thread overview]
Message-ID: <1166786286.6549.24.camel@rosella.wigram> (raw)

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


             reply	other threads:[~2006-12-22 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-22 11:18 skaller [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1166786286.6549.24.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).