Improving std.range.Zip
bearophile
bearophileHUGS at lycos.com
Sun Oct 24 12:39:24 PDT 2010
Tomek S.:
> map!((a) {return myNaryFun(a._0, a._1, ...); })(zip(range1, range2, ...));
Currently the docs of std.algorithm.map say:
>Multiple functions can be passed to map. In that case, the element type of map is a tuple containing one element for each function.<
But lot of time ago I have said that in my opinion that's not the best design. Python has a different design, its map does what you want, you may write your code in Python as:
map(myNaryFun, range1, range2, ...)
An example (Python 2.6):
>>> a = ["a", "b", "c", "d"]
>>> b = [1, 2, 3, 4]
>>> map(lambda c,n: c * n, a, b)
['a', 'bb', 'ccc', 'dddd']
Is is possible to change the std.algorithm.map to a semantics similar to the Python one, that I think is more useful?
Bye,
bearophile
More information about the Digitalmars-d
mailing list