spir: > Yes, this is the only nice looking, high-level, and D-style solution.
I have added: http://d.puremagic.com/issues/show_bug.cgi?id=5466 > While I by far prefer avoiding stringcode: > auto r = map!((p) (tuple(p[0]*10, p[1]~p[1])) (aa.byPair()); > where p means pair; should be correct, should'nt it? If you use a lambda template you need braces and the return statement: auto r = map!((p){ return tuple(p[0]*10, p[1]~p[1]); })(aa.byPair()); > I think for a newcomer the most difficult part is related to tuples: > * find them (in std.typecons!!!) > * catch after much time, pains, research, they should not even try to > construct a tuple using Tuple!, but using the convenience tuple() func > instead. I agree that like dynamic arrays, tuples are better as built-ins, in D too. Another very useful thing is tuple unpacking syntax: http://d.puremagic.com/issues/show_bug.cgi?id=4579 > And also that map expects a range, which an AA is not according to my > trials (code rejected at link time until I used byKey). Or am I wrong? You aren't wrong. > PS: sh*t, I cannot have this work, what's wrong? > > auto pairs = map! > ((int i) {return tuple(10*i, aa[i]~aa[i]);}) > (aa.byKey()); Look at the answers by Simen kjaeraas in this thread, he has explained the situation. Bye, bearophile