当前位置: 首页>>代码示例>>C#>>正文


C# Runner.MLabel方法代码示例

本文整理汇总了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();
        }
开发者ID:panesofglass,项目名称:StateMonad,代码行数:32,代码来源:Exercise2.cs

示例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();
        }
开发者ID:panesofglass,项目名称:StateMonad,代码行数:12,代码来源:Exercise1.cs


注:本文中的Runner.MLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。