-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1906a3f
commit f2c6ccd
Showing
311 changed files
with
8,040 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Docs/SuperLinq.Docs/apidoc/SuperLinq/AggregateBy/AggregateBy1.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 19); | ||
|
||
// Aggregate elements in a sequence grouped by key | ||
var result = sequence | ||
.AggregateBy( | ||
x => x % 3, | ||
0, | ||
(acc, e) => acc + e); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 70], [2, 57], [0, 63]] |
21 changes: 21 additions & 0 deletions
21
Docs/SuperLinq.Docs/apidoc/SuperLinq/AggregateBy/AggregateBy2.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Query Kind="Statements"> | ||
<Reference Relative="..\..\..\..\..\Source\SuperLinq\bin\Release\net7.0\SuperLinq.dll">C:\Users\stuar\source\repos\viceroypenguin\SuperLinq\Source\SuperLinq\bin\Release\net7.0\SuperLinq.dll</Reference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 19); | ||
|
||
// Aggregate elements in a sequence grouped by key | ||
var result = sequence | ||
.AggregateBy( | ||
x => x % 3, | ||
k => k * 1_000, | ||
(acc, e) => acc + e); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 1070], [2, 2057], [0, 63]] |
15 changes: 15 additions & 0 deletions
15
Docs/SuperLinq.Docs/apidoc/SuperLinq/AggregateRight/AggregateRight1.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var numbers = new string[] { "1", "2", "3", "4", "5", }; | ||
|
||
// Enumerate strings from right to left and collect the text into larger strings. | ||
var result = numbers | ||
.AggregateRight((a, b) => $"({a}/{b})"); | ||
|
||
Console.WriteLine(result); | ||
|
||
// This code produces the following output: | ||
// (1/(2/(3/(4/5)))) |
15 changes: 15 additions & 0 deletions
15
Docs/SuperLinq.Docs/apidoc/SuperLinq/AggregateRight/AggregateRight2.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var numbers = new string[] { "1", "2", "3", "4", "5", }; | ||
|
||
// Enumerate strings from right to left and collect the text into larger strings. | ||
var result = numbers | ||
.AggregateRight("6", (a, b) => $"({a}/{b})"); | ||
|
||
Console.WriteLine(result); | ||
|
||
// This code produces the following output: | ||
// (1/(2/(3/(4/(5/6))))) |
18 changes: 18 additions & 0 deletions
18
Docs/SuperLinq.Docs/apidoc/SuperLinq/AggregateRight/AggregateRight3.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var numbers = new string[] { "1", "2", "3", "4", "5", }; | ||
|
||
// Enumerate strings from right to left and collect the text into larger strings. | ||
var result = numbers | ||
.AggregateRight( | ||
"6", | ||
(a, b) => $"({a}/{b})", | ||
s => s.Length); | ||
|
||
Console.WriteLine(result); | ||
|
||
// This code produces the following output: | ||
// 21 |
28 changes: 28 additions & 0 deletions
28
Docs/SuperLinq.Docs/apidoc/SuperLinq/AssertCount/AssertCount.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var numbers = new string[] { "1", "2", "3", "4", "5", }; | ||
|
||
// Enumerate the sequence with a valid length. | ||
// This code executes normally. | ||
numbers | ||
.AssertCount(5) | ||
.Consume(); | ||
|
||
// Enumerate the sequence with an invalid length. | ||
// This code throws an `ArgumentException` | ||
try | ||
{ | ||
numbers | ||
.AssertCount(4) | ||
.Consume(); | ||
} | ||
catch (ArgumentException ae) | ||
{ | ||
Console.WriteLine(ae.Message); | ||
|
||
// This code produces the following output: | ||
// Parameter "source.Count()" (int) must be equal to <4>, was <5>. (Parameter 'source.Count()') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 5); | ||
|
||
foreach (var x in Enumerable.Range(3, 5)) | ||
{ | ||
// Check that a sequence has a minimum size | ||
var result = sequence.AtLeast(x); | ||
|
||
Console.WriteLine($"AtLeast {x}: {result}"); | ||
} | ||
|
||
// This code produces the following output: | ||
// AtLeast 3: True | ||
// AtLeast 4: True | ||
// AtLeast 5: True | ||
// AtLeast 6: False | ||
// AtLeast 7: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 5); | ||
|
||
foreach (var x in Enumerable.Range(3, 5)) | ||
{ | ||
// Check that a sequence has a maximum length | ||
var result = sequence.AtMost(x); | ||
|
||
Console.WriteLine($"AtMost {x}: {result}"); | ||
} | ||
|
||
// This code produces the following output: | ||
// AtMost 3: False | ||
// AtMost 4: False | ||
// AtMost 5: True | ||
// AtMost 6: True | ||
// AtMost 7: True |
16 changes: 16 additions & 0 deletions
16
Docs/SuperLinq.Docs/apidoc/SuperLinq/Backsert/Backsert.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var first = Enumerable.Range(1, 5); | ||
var second = Enumerable.Range(1, 5); | ||
|
||
// Insert one sequence into another | ||
var result = first | ||
.Backsert(second, 2); | ||
|
||
Console.WriteLine(string.Join(", ", result)); | ||
|
||
// This code produces the following output: | ||
// 1, 2, 3, 1, 2, 3, 4, 5, 4, 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
|
||
// Break the sequence of numbers into three chunks of 3 and one chunk of 1 | ||
var result = sequence.Batch(3); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join( | ||
", ", | ||
result.Select(c => "[" + string.Join(", ", c) + "]")) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
|
||
// Break the sequence of numbers into three chunks of 3 and one chunk of 1 | ||
var result = sequence | ||
.Batch( | ||
3, | ||
c => "[" + string.Join(", ", c) + "]"); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
|
||
// Break the sequence of numbers into three chunks of 3 and one chunk of 1 | ||
var buffer = new int[3]; | ||
var result = sequence | ||
.Batch( | ||
buffer, | ||
c => "[" + string.Join(", ", c) + "]"); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
|
||
// Break the sequence of numbers into three chunks of 3 and one chunk of 1 | ||
var buffer = new int[5]; | ||
var result = sequence | ||
.Batch( | ||
buffer, | ||
3, | ||
c => "[" + string.Join(", ", c) + "]"); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] |
19 changes: 19 additions & 0 deletions
19
Docs/SuperLinq.Docs/apidoc/SuperLinq/BindByIndex/BindByIndex1.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
var indices = new int[] { 0, 1, 8, 9, 3, 4, 2, }; | ||
|
||
// Select elements from sequence using the values in indices | ||
var result = sequence | ||
.BindByIndex(indices); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [1, 2, 9, 10, 4, 5, 3] |
22 changes: 22 additions & 0 deletions
22
Docs/SuperLinq.Docs/apidoc/SuperLinq/BindByIndex/BindByIndex2.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
var indices = new int[] { 0, 1, 8, 10, 3, 4, 2, }; | ||
|
||
// Select elements from sequence using the values in indices | ||
var result = sequence | ||
.BindByIndex( | ||
indices, | ||
(e, i) => e.ToString(), | ||
i => "null"); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [1, 2, 9, null, 4, 5, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
|
||
// Break the sequence of numbers into three chunks of 3 and one chunk of 1 | ||
var result = sequence.Buffer(3); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join( | ||
", ", | ||
result.Select(c => "[" + string.Join(", ", c) + "]")) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var sequence = Enumerable.Range(1, 10); | ||
|
||
// Break the sequence of numbers into overlapping chunks of size 3 | ||
var result = sequence.Buffer(3, 2); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join( | ||
", ", | ||
result.Select(c => "[" + string.Join(", ", c) + "]")) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10]] |
18 changes: 18 additions & 0 deletions
18
Docs/SuperLinq.Docs/apidoc/SuperLinq/Cartesian/Cartesian.linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Query Kind="Statements"> | ||
<NuGetReference>SuperLinq</NuGetReference> | ||
<Namespace>SuperLinq</Namespace> | ||
</Query> | ||
|
||
var seq1 = new[] { 1, 2, 3, }; | ||
var seq2 = new[] { "foo", "bar", "quz", }; | ||
|
||
// Take a slice of the sequence | ||
var result = seq1.Cartesian(seq2); | ||
|
||
Console.WriteLine( | ||
"[" + | ||
string.Join(", ", result) + | ||
"]"); | ||
|
||
// This code produces the following output: | ||
// [(1, foo), (1, bar), (1, quz), (2, foo), (2, bar), (2, quz), (3, foo), (3, bar), (3, quz)] |
Oops, something went wrong.