I'm not very experienced in LINQ so forgive me if I'm slow.
I have a LINQ query that looks like this
(from house in Region.Town
let radiusSq = (from neighbor in Region.Town
let distanceSq = Calc.DistanceSq(house.Position, neighbor.Position)
orderby radiusSq descending
As you can see there are let clauses. Does LINQ for C++ account for these?
Jun 11, 2014 at 7:38 PM
Sorry for the late answer.
In LINQ for C# let is implemented in terms of Select (which cpplinq do support). Let's look how C# translates your LINQ expression above before compiling it:
.Select (house =>
house = house,
// This is the let expression
radiusSq = Region.Town.Select(neighbor =>
neighbor = neighbor,
distanceSq = Calc.DistanceSq(house.Position, neighbor.Position)
.OrderBy(v => v.distanceSq)
.Select (v => v.distanceSq)
.OrderBy (v => v.radiusSq)
.Select (v => v.house)
cpplinq is perhaps a little bit misnamed because it doesn't support the C# LINQ syntax (ie what you wrote) but do support the functional way of working collections as popularized by LINQ for C#.
Hope this helped