Make a hash out of two ranges

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Feb 27 20:50:21 PST 2013


On 2/28/13, Chris Cain <clcain at 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.

On 2/28/13, bearophile <bearophileHUGS at lycos.com> wrote:
> See:
> http://dlang.org/phobos/std_array.html#.assocArray

Same answer as above.

My custom range implementation shows exactly what I was trying to use
map for. It only seems natural to me to have this ability, but maybe
map!() can't be customized for this use. Anyway I'm satisfied with my
approach unless you can make map!() do the same thing with some zip
tricks or something.


More information about the Digitalmars-d-learn mailing list