List Comprehension equivalent
Russel Winder via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 17 12:30:43 PDT 2017
On Fri, 2017-03-17 at 19:21 +0000, John Colvin via Digitalmars-d-learn
wrote:
> […]
>
> reduce is a free function in std.algorithm. Just import it and
> you're away. Anyway, is this what you wanted?
>
> string[] blah(string[][string] groups)
> {
> import std.algorithm : map, joiner;
> import std.array : array, byPair;
> return groups.byPair()
> .map!(a =>
> a[1].sort!debianPackageNumberComparator()[0..$-1])
> .joiner
> .array;
> }
Yes it is. I had failed to import joiner in previous experiments.
I feel sufficiently like an idiot now, that I shall imbibe excessively
of the Ricard.
However on the upside the code work very declaratively. :-)
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20170317/5346154c/attachment.sig>
More information about the Digitalmars-d-learn
mailing list