On Thursday, 28 February 2013 at 04:50:34 UTC, Andrej Mitrovic
wrote:
On 2/28/13, Chris Cain <clc...@uncg.edu> wrote:
Map in std.algorithm doesn't really work like that. Many
languages use "map" to mean hashing items, but "map" in
functional programming (and D) really means something more like
"apply this function to each item."
I know that, I was expecting it to work with multiple ranges if
the
functor takes multiple arguments.
If you're trying to create an associative array from two arrays
A *lazy* range of associative arrays.
Aha, I see now. Here you go:
zip([1,3], [2,4])
.map!(e => [e[0] : e[1]])()
.writeln();
zip gives out a tuple, so I wish it were possible to do
.map!((a,b) => [a : b])()
instead and have it appropriately use the elements of the tuple.
Maybe that'd be a potential enhancement possibility for map?