I have a bit of code:

        string[] returnValue;
        foreach(string key, string[] value; groups) {
                returnValue ~= 
value.sort!debianPackageNumberComparator()[0..$-1].array;
        }
        return returnValue;

which does seem to do the thing required, but this sort of code in
Python, Rust, even C++ (but not Go), would be seen as for too "changing
state", not declarative enough. With Python you use list comprehensions
(which are lovely things), in Rust you can do flat_map and collect. I
am fighting in D starting from:

        return groups.byPair()
         .map((Tuple!(string, string[]) a) => 
a[1].sort!debianPackageNumberComparator()[0..$-1])
         .array
         .joiner;

because the compiler keeps complaining about:


ldc2  '-Isource/approx-gc@exe' '-Isource' 
'-I../../Repositories/Git/Masters/ApproxGC_D/source' '-enable-color' '-wi' 
'-O3' '-release'  -of 'source/approx-gc@exe/main.d.o' -c 
../../Repositories/Git/Masters/ApproxGC_D/source/main.d
../../Repositories/Git/Masters/ApproxGC_D/source/main.d(75): Error: template 
std.algorithm.iteration.map cannot deduce function from argument types 
!()(MapResult!(__lambda2, Result), SortedRange!(string[], 
debianPackageNumberComparator) function(Tuple!(string, string[]) a) @system), 
candidates are:
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/algorithm/iteration.d(448):        
std.algorithm.iteration.map(fun...) if (fun.length >= 1)

Anyone any idea on how to move forward on this?

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to