« MoreLINQ » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
Ligne 23 : Ligne 23 :
// [7, 8, 9]
// [7, 8, 9]
// [10]
// [10]
</kode>
== Cartesian ==
Returns the Cartesian product of two or more sequences by combining each element from the sequences and applying a user-defined projection to the set.
<kode lang='cs'>
Enumerable
    .Range(1, 2)
    .Cartesian(
        Enumerable.Range(10, 2),
        (x, y) => $"{x} - {y}");
// 1 - 10
// 1 - 11
// 2 - 10
// 2 - 11
</kode>
</kode>

Version du 14 novembre 2020 à 22:37

Links

Add

Bash.svg
dotnet add package MoreLINQ

Operators

Aggregate

Batch

Batches the source sequence into sized buckets.

Cs.svg
Enumerable
    .Range(1, 10)
    .Batch(3);  // split the sequence into sequences of max length 3
// [1, 2, 3]
// [4, 5, 6]
// [7, 8, 9]
// [10]

Cartesian

Returns the Cartesian product of two or more sequences by combining each element from the sequences and applying a user-defined projection to the set.

Cs.svg
Enumerable
    .Range(1, 2)
    .Cartesian(
        Enumerable.Range(10, 2),
        (x, y) => $"{x} - {y}");
// 1 - 10
// 1 - 11
// 2 - 10
// 2 - 11