projections in D

Ramon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 24 06:00:49 PST 2014


what range/algorithm allows me to make projections from one 
sequence to another?

that is, in C#, this is the Select method 
(http://msdn.microsoft.com/en-us/library/vstudio/bb548891%28v=vs.100%29.aspx)

example in C#:

class ProjectionWanted
{
   public int field1 { get; set; }
   public int field2 { get; set; }
   public int field3 { get; set; }
}

void Foo(List<ProjectionWanted> list)
{
   var list_projected = list.Select(l => new { l.field1, l.field2 
});
   // list_projected elements now contain only field1 and field2
}

So how would I make it in D? First yet, does D supports creating 
anonymous type for the projection? Or maybe I need to declare the 
class/struct that I want to be projected?


More information about the Digitalmars-d-learn mailing list