Is logical subsetting of an array possible ?

Sahil via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 14 04:03:07 PDT 2016


On Thursday, 14 July 2016 at 10:51:33 UTC, Nicholas Wilson wrote:
> On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote:
>> This is with reference to documentation about use of array in 
>> D (https://dlang.org/spec/arrays.html#array-setting).

> easily. The function you are looking for is called 'filter'
>
> import std.algorithm;
> import std.array;
> int[] a = [ 4,5,8,1,3,2,9,10];
> auto b = a.filter!(e => e>3).array; //b contains the elements 
> 4,5,8,9,10

Thanks for a prompt reply. This gives me confidence to explore D 
for faster implementations in data mining.
Thanks a lot :-)


More information about the Digitalmars-d-learn mailing list