本文整理汇总了C#中Runner.MLabel方法的典型用法代码示例。如果您正苦于以下问题:C# Runner.MLabel方法的具体用法?C# Runner.MLabel怎么用?C# Runner.MLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Runner
的用法示例。
在下文中一共展示了Runner.MLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run(Tree<string> tree, Tuple<double, Rect> seed)
{
Func<StateMonad<Tuple<double, Rect>, Tuple<double, Rect>>> leftUpdater = () =>
new StateMonad<Tuple<double, Rect>, Tuple<double, Rect>>(m =>
{
var depth = m.First;
var rect = m.Second;
var newDepth = depth + 1.0;
var multiplier = 2.0 * newDepth;
var nextRect = new Rect(rect.Height, rect.Width / multiplier, rect.Top, rect.Left + rect.Width / multiplier);
var currRect = new Rect(rect.Height, rect.Width / multiplier, rect.Top, rect.Left);
return Tuple.Create(Tuple.Create(newDepth, nextRect), Tuple.Create(newDepth, currRect));
});
Func<StateMonad<Tuple<double, Rect>, Tuple<double, Rect>>> rightUpdater = () =>
new StateMonad<Tuple<double, Rect>, Tuple<double, Rect>>(m =>
{
var depth = m.First;
var rect = m.Second;
var newDepth = depth - 1.0;
var nextRect = new Rect(rect.Height, rect.Width * 2, rect.Top, rect.Left + rect.Width);
return Tuple.Create(Tuple.Create(newDepth, nextRect), m);
});
var runner = new Runner<Tuple<double, Rect>, string>(leftUpdater, rightUpdater);
Console.WriteLine();
Console.WriteLine("Exercise 2: Tree within bounded rects:");
var rectTree = runner.MLabel(tree, seed);
rectTree.Show(2);
Console.WriteLine();
}
示例2: Run
public static void Run(Tree<string> tree, int seed)
{
Func<StateMonad<int, int>> incrementer = () => new StateMonad<int, int>(n => Tuple.Create(n + 1, n));
var runner = new Runner<int, string>(incrementer);
Console.WriteLine();
Console.WriteLine("Exercise 1: Monadically Labeled Tree:");
var t3 = runner.MLabel(tree, seed);
t3.Show(2);
Console.WriteLine();
}