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


C# FSharpList.Any方法代码示例

本文整理汇总了C#中FSharpList.Any方法的典型用法代码示例。如果您正苦于以下问题:C# FSharpList.Any方法的具体用法?C# FSharpList.Any怎么用?C# FSharpList.Any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FSharpList的用法示例。


在下文中一共展示了FSharpList.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: __eval_internal_recursive

        protected virtual void __eval_internal_recursive(FSharpList<FScheme.Value> args, Dictionary<PortData, FScheme.Value> outPuts, int level = 0)
        {
            var argSets = new List<FSharpList<FScheme.Value>>();

            //create a zip of the incoming args and the port data
            //to be used for type comparison
            var portComparison =
                args.Zip(InPortData, (first, second) => new Tuple<Type, Type>(first.GetType(), second.PortType))
                    .ToList();
            var listOfListComparison = args.Zip(InPortData,
                (first, second) => new Tuple<bool, Type>(Utils.IsListOfLists(first), second.PortType));

            //there are more than zero arguments
            //and there is either an argument which does not match its expections
            //OR an argument which requires a list and gets a list of lists
            //AND argument lacing is not disabled
            if (ArgumentLacing != LacingStrategy.Disabled && args.Any() &&
                (portComparison.Any(x => x.Item1 == typeof (Value.List) && x.Item2 != typeof (Value.List)) ||
                    listOfListComparison.Any(x => x.Item1 && x.Item2 == typeof (Value.List))))
            {
                //if the argument is of the expected type, then
                //leave it alone otherwise, wrap it in a list
                int j = 0;
                foreach (var arg in args)
                {
                    //incoming value is list and expecting single
                    if (portComparison.ElementAt(j).Item1 == typeof (Value.List) &&
                        portComparison.ElementAt(j).Item2 != typeof (Value.List))
                    {
                        //leave as list
                        argSets.Add(((Value.List) arg).Item);
                    }
                        //incoming value is list and expecting list
                    else
                    {
                        //check if we have a list of lists, if so, then don't wrap
                        argSets.Add(
                            Utils.IsListOfLists(arg) && !AcceptsListOfLists(arg)
                                ? ((Value.List) arg).Item
                                : Utils.MakeFSharpList(arg));
                    }
                    j++;
                }

                IEnumerable<IEnumerable<Value>> lacedArgs = null;
                switch (ArgumentLacing)
                {
                    case LacingStrategy.First:
                        lacedArgs = argSets.SingleSet();
                        break;
                    case LacingStrategy.Shortest:
                        lacedArgs = argSets.ShortestSet();
                        break;
                    case LacingStrategy.Longest:
                        lacedArgs = argSets.LongestSet();
                        break;
                    case LacingStrategy.CrossProduct:
                        lacedArgs = argSets.CartesianProduct();
                        break;
                }

                var evalResult = OutPortData.ToDictionary(
                    x => x,
                    _ => FSharpList<Value>.Empty);

                var evalDict = new Dictionary<PortData, Value>();

                //run the evaluate method for each set of
                //arguments in the lace result.
                foreach (var argList in lacedArgs)
                {
                    evalDict.Clear();

                    var thisArgsAsFSharpList = Utils.ToFSharpList(argList);

                    var portComparisonLaced =
                        thisArgsAsFSharpList.Zip(InPortData,
                            (first, second) => new Tuple<Type, Type>(first.GetType(), second.PortType)).ToList();

                    int jj = 0;
                    bool bHasListNotExpecting = false;
                    foreach (var argLaced in argList)
                    {
                        //incoming value is list and expecting single
                        if (ArgumentLacing != LacingStrategy.Disabled && thisArgsAsFSharpList.Any() &&
                            portComparisonLaced.ElementAt(jj).Item1 == typeof (Value.List) &&
                            portComparison.ElementAt(jj).Item2 != typeof (Value.List) &&
                            (!AcceptsListOfLists(argLaced) || !Utils.IsListOfLists(argLaced))
                            )
                        {
                            bHasListNotExpecting = true;
                            break;
                        }
                        jj++;
                    }
                    if (bHasListNotExpecting)
                    {
                        if (level > 20)
                            throw new Exception("Too deep recursive list containment by lists, only 21 are allowed");
                        Dictionary<PortData, FScheme.Value> outPutsLevelPlusOne =
//.........这里部分代码省略.........
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:101,代码来源:NodeModel.cs

示例2: __eval_internal

        protected internal virtual void __eval_internal(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
        {
            var argList = new List<string>();
            if (args.Any())
            {
                argList = args.Select(x => x.ToString()).ToList<string>();
            }
            var outPutsList = new List<string>();
            if(outPuts.Any())
            {
                outPutsList = outPuts.Keys.Select(x=>x.NickName).ToList<string>();
            }

            //Debug.WriteLine(string.Format("__eval_internal : {0} : {1}",
            //    string.Join(",", argList),
            //    string.Join(",", outPutsList)));
            Evaluate(args, outPuts);
        }
开发者ID:kentvv,项目名称:Dynamo,代码行数:18,代码来源:dynNodeModel.cs


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