As many thanks As possible to who crates D and UFCS feature
k-five via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 12 04:58:23 PDT 2017
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 ) );
More information about the Digitalmars-d-learn
mailing list