[Issue 8715] zipWith
http://d.puremagic.com/issues/show_bug.cgi?id=8715 --- Comment #4 from bearophile_h...@eml.cc 2012-10-12 16:22:58 PDT --- (In reply to comment #3) (map already accepts a struct with an appropriate constructor as that fits the 'callable' definition.) Right. But this shows a different limit. I think code like this is accepted in Clojure: import std.algorithm: map; void main() { auto keys = [1, 2, 1, 1, 1]; auto a = [0, 10, 20]; auto r1 = map!(k = a[k])(keys); // OK auto r2 = map!a(keys); // Error auto aa = [1: 10, 2: 20]; auto r3 = map!(k = aa[k])(keys); // OK auto r4 = map!aa(keys); // Error } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8715] zipWith
http://d.puremagic.com/issues/show_bug.cgi?id=8715 timon.g...@gmx.ch changed: What|Removed |Added CC||timon.g...@gmx.ch --- Comment #1 from timon.g...@gmx.ch 2012-09-23 16:34:39 PDT --- I suggest to add anything that is not yet there and applicable to ranges listed here up to and excluding 'special lists': http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8715] zipWith
http://d.puremagic.com/issues/show_bug.cgi?id=8715 --- Comment #2 from bearophile_h...@eml.cc 2012-09-23 17:48:57 PDT --- A simpler alternative idea is to just extend zip() to optionally accept a function/constructor (it's also good for map() to accept a struct name): import std.range; void main() { auto r1 = zip!q{a + b}([1,2,3], [10,20,30]); static struct Vec { int x, y; } auto r2 = zip!Vec([1,2,3], [10,20,30]); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 8715] zipWith
http://d.puremagic.com/issues/show_bug.cgi?id=8715 --- Comment #3 from timon.g...@gmx.ch 2012-09-23 18:04:46 PDT --- (In reply to comment #2) A simpler alternative idea is to just extend zip() to optionally accept a function/constructor (it's also good for map() to accept a struct name): import std.range; void main() { auto r1 = zip!q{a + b}([1,2,3], [10,20,30]); static struct Vec { int x, y; } auto r2 = zip!Vec([1,2,3], [10,20,30]); } I prefer this. 'zip' would become 'zipWith' with a default template argument of 'tuple'. (map already accepts a struct with an appropriate constructor as that fits the 'callable' definition.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---