[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-12-22 (11:19) |
From: | skaller <skaller@u...> |
Subject: | map and fold |
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