What's equivalent to C#'s select?
Marc
jckj33 at gmail.com
Sun Jan 14 22:07:22 UTC 2018
On Sunday, 14 January 2018 at 21:38:39 UTC, drug wrote:
> 15.01.2018 00:21, Marc пишет:
>> give a list, how can I select only the elements of a range
>> according to a condition give by a lamba function?
>>
>> something like this:
>>
>>> auto l = myList.select(e => e.id < 300);
>>
>> it would return a range. Similar to C#'s select:
>>
>> https://msdn.microsoft.com/en-us/library/bb548891(v=vs.110).aspx
> import std.algorithm : filter;
>
> auto l = myList.filter!(e => e.id < 300);
thanks, can i use it at compile time as well?
> enum isMutableString(string field) =
>is(typeof(__traits(getMember, >C, field)) == string);
> static foreach(field; [FieldNameTuple!C].filter!(f =>
>>isMutableString!(f))) {
> writeln(field);
> }
give error:
> Error: variable f cannot be read at compile time
More information about the Digitalmars-d-learn
mailing list