Re: What's equivalent to C#'s select?

2018-01-15 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 15 January 2018 at 15:24:50 UTC, Marc wrote: I just thought that filter() could be evaluated at compile time too, as others function that I've used so far. Sometimes I don't know if a native function can be evaluated at compile time until I do enum x = func(); Yeah, it takes some

Re: What's equivalent to C#'s select?

2018-01-15 Thread Marc via Digitalmars-d-learn
On Monday, 15 January 2018 at 07:37:42 UTC, Simen Kjærås wrote: On Sunday, 14 January 2018 at 22:07:22 UTC, Marc wrote: thanks, can i use it at compile time as well? enum isMutableString(string field) = is(typeof(__traits(getMember, >C, field)) == string); static foreach(field;

Re: What's equivalent to C#'s select?

2018-01-14 Thread Simen Kjærås via Digitalmars-d-learn
On Sunday, 14 January 2018 at 22:07:22 UTC, Marc wrote: 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))) {

Re: What's equivalent to C#'s select?

2018-01-14 Thread Marc via Digitalmars-d-learn
On Sunday, 14 January 2018 at 21:59:26 UTC, Seb wrote: On Sunday, 14 January 2018 at 21:21:52 UTC, Marc wrote: 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

Re: What's equivalent to C#'s select?

2018-01-14 Thread Marc via Digitalmars-d-learn
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.

Re: What's equivalent to C#'s select?

2018-01-14 Thread Seb via Digitalmars-d-learn
On Sunday, 14 January 2018 at 21:21:52 UTC, Marc wrote: 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:

Re: What's equivalent to C#'s select?

2018-01-14 Thread drug via Digitalmars-d-learn
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:

What's equivalent to C#'s select?

2018-01-14 Thread Marc via Digitalmars-d-learn
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