本文整理汇总了C#中Func.Arr方法的典型用法代码示例。如果您正苦于以下问题:C# Func.Arr方法的具体用法?C# Func.Arr怎么用?C# Func.Arr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func.Arr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFirstDistributivity
public static bool TestFirstDistributivity()
{
var f = new Func<int, int>(x => x * 3 - 2);
var g = new Func<int, int>(y => (y + 2) / 3);
var id = new Func<int, int>(x => x);
var unDistributed = f.Arr(g).First(default(int));
var distributed = (f.Mult(id)).Arr(g.Mult(id));
return ArrowTestUtils.AssertPairInvertibleArrowsGiveSameOutput(distributed, unDistributed);
}
示例2: TestCompositionDistributivity
public static bool TestCompositionDistributivity()
{
var f1 = new Func<int, int>(x => x * 2);
var f2 = new Func<int, int>(x => x - 1);
var g1 = new Func<int, int>(x => x / 2);
var g2 = new Func<int, int>(x => x + 1);
var undistributed = f1.Arr(g1).Combine(f2.Arr(g2));
var distributed = new Func<int, int>(x => f2(f1(x)))
.Arr(new Func<int, int>(y => g1(g2(y))));
return ArrowTestUtils.AssertInvertibleArrowsGiveSameOutput(undistributed, distributed);
}
示例3: TestInversionCorrectness
public static bool TestInversionCorrectness()
{
var f = new Func<int, int>(x => x * 3);
var g = new Func<int, int>(y => y / 3);
var inverted = f.Arr(g).Invert();
var actuallyInverse = g.Arr(f);
return ArrowTestUtils.AssertInvertibleArrowsGiveSameOutput(inverted, actuallyInverse);
}