本文整理汇总了C#中Range.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# Range.SelectMany方法的具体用法?C# Range.SelectMany怎么用?C# Range.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.SelectMany方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResults
public IEnumerable<IEnumerable<int>> GetResults(BooleanMatrix pairs, int count, ImmutableSequence<int> current)
{
int length = pairs.Width;
int start;
if (!current.HasValue)
{
start = 0;
}
else
{
start = current.First();
}
var results = new Range(start, length)
.Where(i => current
.All(x => pairs[x, i]));
if (count == 1)
{
return results
.Select(i => new ImmutableSequence<int>(i, current));
}
else
{
return results
.SelectMany(i => GetResults(pairs, count - 1, new ImmutableSequence<int>(i, current)));
}
}
示例2: CalculateResult
public override object CalculateResult()
{
var abundantNumbers = new Range(1, UpperLimit)
.Where(n => new FactorGenerator(n, false)
.Sum() > n)
.ToArray();
return abundantNumbers
.SelectMany((a, i) => abundantNumbers
.Take(i + 1)
.Select(b => a + b)
.TakeWhile(n => n < UpperLimit))
.ToInt32Set(UpperLimit)
.GetInverse()
.Sum();
}
示例3: CalculateResult
public override object CalculateResult()
{
var cubes = new Range(0, 9, true)
.GetCombinations(6)
.ToArray();
var squares = new Range(1, 9, true)
.Select(n => n * n)
.ToHashSet();
var numberTransforms = new Range(0, 9, true)
.ToDictionary(n => n, n => n == 6 || n == 9 ? new[] { 6, 9 } : new[] { n });
return cubes
.SelectMany((c1, i) => cubes.Skip(i)
.Select(c2 => new { Cube1 = c1, Cube2 = c2 }))
.Select(x => x.Cube1
.SelectMany(a => x.Cube2
.SelectMany(b => numberTransforms[a]
.SelectMany(i => numberTransforms[b]
.SelectMany(j => new[] { i * 10 + j, j * 10 + i })))))
.Count(x => squares.IsSubsetOf(x));
}