12.05.2017 14:58, k-five пишет:
On Friday, 12 May 2017 at 11:41:57 UTC, cym13 wrote:
On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote:
-------------------------------------------------------
Shorter:
void main( string[] args ){
dirEntries( ".", SpanMode.depth, false )
.filter!( file => !file.name.matchFirst( regex( args[ 1 ] )
).empty() )
.filter!( file => ( args[ 2 ] == "-f" || args[ 2 ] == "-d" ?
( args[ 2 ] == "-f" ? !file.isDir : !file.isFile ) : ( !file.isSymlink
) ) )
.map!( file => file.name )
.each!(string item => writeln( item ));
}
It's more memory efficient too because at no point the actual list is
stored.
---------------------------------------------------------
Thanks and the correct syntax for each! is, passing a lambda. So the:
.each!(string item => writeln( item ));
is an error:
temp.d(15): Error: found 'item' when expecting ')' following template
argument list ...
and should be:
.each!( ( string item ) => writeln( item ) );
also .each!writeln should be possible