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

Reply via email to