A mapping of the feature set of the LINQ API to D's Range API.
LINQ | D |
---|---|
Where |
filter |
OfTyp |
castSwitch |
LINQ | D |
---|---|
Select |
map |
SelectMany |
= |
Anonoymous Types | Tuples |
Indexed | enumerate |
from c in customers
from o in c.Orders
where c.Region == "WA"
LINQ | D |
---|---|
Take |
take |
Skip |
drop |
TakeWhile |
until |
SkipWhile |
find |
LINQ | D |
---|---|
OrderBy |
sort |
OrderBy + Comparer |
sort + opCmp |
OrderByDescending |
sort |
OrderByDescending + Comparer |
sort + opCmp |
ThenBy |
multiSort |
ThenBy + Comparer |
multiSort + opCmp |
ThenByDescending |
multiSort |
ThenByDescending + Comparer |
multiSort + opCmp |
Reverse |
retro |
LINQ | D |
---|---|
GroupBy |
chunkBy , group |
GroupJoin |
Grouping: https://msdn.microsoft.com/en-us/library/mt693097.aspx
LINQ | D |
---|---|
Distinct |
uniq |
Union |
merge |
Intersect |
setIntersection |
Except |
setDifference |
D expects sortedness of all inputs.
LINQ | D |
---|---|
ToArray |
array |
ToList |
array |
ToDictionary |
assocArray |
ToLookup |
chunkby.assocArray |
Cast |
no need (universal API) |
AsQueryable |
isInputRange |
AsEnumerable |
isRandomAccessRange |
OfType | typeof |
LINQ | D |
---|---|
First |
front |
FirstOrDefault |
r.empty ? "default" : r.front |
ElementAt |
[[] ] |
ElementAtOrDefault |
i < r.length ? "default" : r[i] |
Last |
back |
LastOrDefault |
r.empty ? "default" : r.front |
Single |
r.length == 1 ? r.front : throw new Exception("Range is supposed to contain a single value only") |
SingleOrDefault |
r.length <= 1 ? (r.empty ? "default" : r.front ) : throw new Exception("Range is supposed to contain a single value only") |
LINQ | D |
---|---|
Range |
iota |
Repeat |
repeat |
Empty |
empty |
DefaultIfEmpty |
r.empty ? "default" : r.front |
LINQ | D |
---|---|
Any |
any |
All |
all |
Contains |
find , canFind |
LINQ | D |
---|---|
Count |
length if RandomAccess, otherwise walkLength |
Sum |
sum |
Min |
minElement |
Max |
maxElement |
Average |
|
Aggregate |
reduce |
LongCount |
length / walkLength use size_t |
LINQ | D |
---|---|
SequenceEqual |
equal |
LINQ | D |
---|---|
Concat |
chain |
LINQ | D |
---|---|
Deferred Execution | Ranges in D are lazy |
Immediate Execution | e.g. each |
Query Reuse | save |
Custom generator | generate |
- Cross Join
- Group Join
- Cross Join with Group Join
- Left Outer Join