On Tue, 2017-03-14 at 16:35 +0000, Russel Winder wrote: > So by analogy with the Python code I get the following D code, but it seems ugly compared to the niceness of the Groovy code (and equivalent Kotlin and Ceylon codes):
import std.array: array, split; import std.algorithm: filter, map; import std.file: dirEntries, SpanMode; import std.path: baseName, dirName; import std.stdio: writeln; import std.typecons: Tuple, tuple; auto files = dirEntries(path, SpanMode.shallow) .filter!(a => a.isFile) .map!(a => a.baseName) .map!(a => tuple(a.split('_')[0], a)) .array; writeln(files); string[][string] groups; foreach (Tuple!(string, string) f; files) { groups[f[0]] ~= [f[1]]; } -- 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
signature.asc
Description: This is a digitally signed message part