Re: How to get struct's members ?

2014-05-23 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 23 May 2014 at 01:17:18 UTC, bioinfornatics wrote: Dear, I would like to get struct's members and zip them with an action as struct A { int a; int b; } std.range.zip( __traits( allmembers, A ), [(x) = x == 0, (y) = y 3] ); like this i could apply an action to each field. I

Re: How to get struct's members ?

2014-05-23 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, May 23, 2014 at 8:44 AM, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 23 May 2014 at 01:17:18 UTC, bioinfornatics wrote: I would like to get struct's members and zip them with an action tupleof will do what you need (mostly). However, I

Re: How to get struct's members ?

2014-05-23 Thread bioinfornatics via Digitalmars-d-learn
On Friday, 23 May 2014 at 08:20:05 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: On Fri, May 23, 2014 at 8:44 AM, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 23 May 2014 at 01:17:18 UTC, bioinfornatics wrote: I would like to get struct's

Re: How to get struct's members ?

2014-05-23 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 23 May 2014 at 08:20:05 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: On Fri, May 23, 2014 at 8:44 AM, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 23 May 2014 at 01:17:18 UTC, bioinfornatics wrote: I would like to get struct's

Re: How to get struct's members ?

2014-05-23 Thread bioinfornatics via Digitalmars-d-learn
On Friday, 23 May 2014 at 01:17:18 UTC, bioinfornatics wrote: Dear, I would like to get struct's members and zip them with an action as struct A { int a; int b; } std.range.zip( __traits( allmembers, A ), [(x) = x == 0, (y) = y 3] ); like this i could apply an action to each field. I

How to get struct's members ?

2014-05-22 Thread bioinfornatics via Digitalmars-d-learn
Dear, I would like to get struct's members and zip them with an action as struct A { int a; int b; } std.range.zip( __traits( allmembers, A ), [(x) = x == 0, (y) = y 3] ); like this i could apply an action to each field. I tried this: http://dpaste.dzfl.pl/747799ffa64e but: tuple

Re: How to get struct's members ?

2014-05-22 Thread Adam D. Ruppe via Digitalmars-d-learn
allMembers yields the names of all the members. Try .tupleof on an object instead, that might work better.