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


C# FSharpList类代码示例

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


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

示例1: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            var min = ((FScheme.Value.Number)args[0]).Item;
            var max = ((FScheme.Value.Number)args[1]).Item;

            return FScheme.Value.NewContainer(DSCoreNodes.Domain.ByMinimumAndMaximum(min, max));
        }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:7,代码来源:Geometry.cs

示例2: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            if (((Value.Number)args[0]).Item == 1)
            {
                if (port != null)
                {
                    bool isOpen = true;

                    if (isOpen == true)
                    {
                        if (!port.IsOpen)
                        {
                            port.Open();
                        }

                    }
                    else if (isOpen == false)
                    {
                        if (port.IsOpen)
                            port.Close();
                    }
                }
            }

            return Value.NewContainer(port); // pass the port downstream
        }
开发者ID:epeter61,项目名称:Dynamo,代码行数:26,代码来源:dynArduino.cs

示例3: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            var worksheet = (Microsoft.Office.Interop.Excel.Worksheet)((FScheme.Value.Container)args[0]).Item;

            Microsoft.Office.Interop.Excel.Range range = worksheet.UsedRange;

            int rows = range.Rows.Count;
            int cols = range.Columns.Count;

            var rowData = new List<FScheme.Value>();

            for (int r = 1; r <= rows; r++)
            {
                var row = new List<FScheme.Value>();

                for (int c = 1; c <= cols; c++)
                {
                    row.Add(FScheme.Value.NewContainer(range.Cells[r, c].Value2));
                }

                rowData.Add(FScheme.Value.NewList(Utils.SequenceToFSharpList(row)));
            }

            return FScheme.Value.NewList(Utils.SequenceToFSharpList(rowData));
        }
开发者ID:kyoisi,项目名称:Dynamo,代码行数:25,代码来源:dynExcel.cs

示例4: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            var thunk = ((FScheme.Value.Function) args[0]).Item;
            var task = FScheme.MakeFuture(thunk);

            return FScheme.Value.NewContainer(task);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:7,代码来源:dynMultithreading.cs

示例5: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            string prefix = "";

            int count = 0;

            DispatchOnUIThread(
                delegate
                {
                    //unhook the binding
                    OnRequestBindingUnhook(EventArgs.Empty);

                    Root.Children.Clear();

                    foreach (Value e in args)
                    {
                        Root.Children.Add(Process(e, count.ToString(CultureInfo.InvariantCulture), Root.ShowRawData));
                        count++;
                    }

                    //rehook the binding
                    OnRequestBindingRehook(EventArgs.Empty);
                }
                );

            //return the content that has been gathered
            return args[0]; //watch should be a 'pass through' node
        }
开发者ID:jimmplan,项目名称:Dynamo,代码行数:28,代码来源:dynWatch.cs

示例6: Evaluate

        //protected override void OnRunCancelled()
        //{
        //    if (delayThread != null && delayThread.IsAlive)
        //        delayThread.Abort();
        //}
        public override Value Evaluate(FSharpList<Value> args)
        {
            int delay = (int)((Value.Number)args[0]).Item;

            if (delayThread == null || !delayThread.IsAlive)
            {
                delayThread = new Thread(new ThreadStart(
                    delegate
                    {
                        Thread.Sleep(delay);

                        if (Controller.RunCancelled)
                            return;

                        while (Controller.Running)
                        {
                            Thread.Sleep(1);
                            if (Controller.RunCancelled)
                                return;
                        }

                        this.RequiresRecalc = true;
                    }
                ));

                delayThread.Start();
            }

            return Value.NewNumber(1);
        }
开发者ID:epeter61,项目名称:Dynamo,代码行数:35,代码来源:dynTimer.cs

示例7: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            var e = new Expression(Formula);

            var functionLookup = new Dictionary<string, Value>();

            foreach (var arg in args.Select((arg, i) => new { Value = arg, Index = i }))
            {
                var parameter = InPortData[arg.Index].NickName;
                if (arg.Value.IsFunction)
                    functionLookup[parameter] = arg.Value;
                else
                    e.Parameters[parameter] = ((Value.Number)arg.Value).Item;
            }

            e.EvaluateFunction += delegate(string name, FunctionArgs fArgs)
            {
                if (functionLookup.ContainsKey(name))
                {
                    var func = ((Value.Function)functionLookup[name]).Item;
                    fArgs.Result = ((Value.Number)func.Invoke(
                        Utils.SequenceToFSharpList(
                            fArgs.Parameters.Select<Expression, Value>(
                                p => Value.NewNumber(Convert.ToDouble(p.Evaluate())))))).Item;
                }
                else
                {
                    fArgs.HasResult = false;
                }
            };

            return Value.NewNumber(Convert.ToDouble(e.Evaluate()));
        }
开发者ID:epeter61,项目名称:Dynamo,代码行数:33,代码来源:dynEquation.cs

示例8: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            if (SelectedIndex < 0)
            {
                throw new Exception("Please select a mesh node.");
            }

            var node_name = Items[SelectedIndex].Name;

            //             if (InPorts[0].IsConnected)
            //             {
            //                 // send the to the connected node
            //                 return FScheme.Value.NewString(node_name);
            //             }

            var result = FSharpList<FScheme.Value>.Empty;

            if (OutPorts[0].IsConnected)
            {
                // get the data from the connected node
                DynamoMaya.Contract.IService s = MayaCommunication.openChannelToMaya();
                Point3DCollection vertices = s.receiveVertexPositionsFromMaya(node_name);

                foreach (Point3D v in vertices)
                {
                    XYZ pt = new XYZ(v.X, v.Y, v.Z);
                    result = FSharpList<FScheme.Value>.Cons(FScheme.Value.NewContainer(pt), result);
                }

                MayaCommunication.closeChannelToMaya(s);
            }

            return FScheme.Value.NewList(ListModule.Reverse(result));
        }
开发者ID:MrWalsh,项目名称:DynaMaya-WIP,代码行数:34,代码来源:DynamoMayaNodes.cs

示例9: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            Curve thisCurve = (Curve)((Value.Container)args[0]).Item;

            if (thisCurve == null)
            {
                throw new Exception("Not enough reference points to make a curve.");
            }

            Type CurveType = typeof(Autodesk.Revit.DB.Curve);

            MethodInfo[] curveInstanceMethods = CurveType.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

            System.String nameOfMethodApproximateByTangentArcs = "ApproximateByTangentArcs";
            List<Curve> resultArcs = null;
            var result = FSharpList<Value>.Empty;

            foreach (MethodInfo m in curveInstanceMethods)
            {
                if (m.Name == nameOfMethodApproximateByTangentArcs)
                {
                    object[] argsM = new object[0];

                    resultArcs = (List<Curve>)m.Invoke(thisCurve, argsM);

                    break;
                }
            }
            for (int indexCurve = resultArcs.Count - 1; indexCurve > -1; indexCurve--)
            {
                result = FSharpList<Value>.Cons(Value.NewContainer(resultArcs[indexCurve]), result);
            }

            return Value.NewList(result);
        }
开发者ID:parchjs,项目名称:Dynamo,代码行数:35,代码来源:Curve.cs

示例10: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            CurveLoop firstLoop = (CurveLoop)((Value.Container)args[0]).Item;
            CurveLoop secondLoop = (CurveLoop)((Value.Container)args[1]).Item;

            List<VertexPair> vertPairs = null;

            if (dynRevitSettings.Revit.Application.VersionName.Contains("2013"))
            {
                vertPairs = new List<VertexPair>();

                int i = 0;
                int nCurves1 = firstLoop.Count();
                int nCurves2 = secondLoop.Count();
                for (; i < nCurves1 && i < nCurves2; i++)
                {
                    vertPairs.Add(new VertexPair(i, i));
                }
            }

            var result = GeometryCreationUtilities.CreateBlendGeometry(firstLoop, secondLoop, vertPairs);

            solids.Add(result);

            return Value.NewContainer(result);
        }
开发者ID:epeter61,项目名称:Dynamo,代码行数:26,代码来源:dynGeometry.cs

示例11: Evaluate

        public override void Evaluate(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
        {
            var crv1 = (Curve)((Value.Container)args[0]).Item;
            var crv2 = (Curve)((Value.Container)args[1]).Item;

            IntersectionResultArray xsects;
            SetComparisonResult result = crv1.Intersect(crv2, out xsects);

            var xyz = FSharpList<Value>.Empty;
            var u = FSharpList<Value>.Empty;
            var v = FSharpList<Value>.Empty;

            if (xsects != null)
            {
                foreach (IntersectionResult ir in xsects)
                {
                    xyz = FSharpList<Value>.Cons(Value.NewContainer(ir.XYZPoint), xyz);
                    u = FSharpList<Value>.Cons(Value.NewNumber(ir.UVPoint.U), u);
                    v = FSharpList<Value>.Cons(Value.NewNumber(ir.UVPoint.V), v);

                }

            }

            outPuts[_vPort] = Value.NewList(v);
            outPuts[_uPort] = Value.NewList(u);
            outPuts[_xyzPort] = Value.NewList(xyz);
            outPuts[_resultPort] = Value.NewString(result.ToString());
        }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:29,代码来源:Intersect.cs

示例12: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            var crv1 = (Curve)((Value.Container)args[0]).Item;
            var crv2 = (Curve)((Value.Container)args[1]).Item;

            IntersectionResultArray xsects = new IntersectionResultArray();
            SetComparisonResult result = crv1.Intersect(crv2, out xsects);
            var results = FSharpList<Value>.Empty;

            var xsect_results = FSharpList<Value>.Empty;
            if (xsects != null)
            {
                foreach (IntersectionResult ir in xsects)
                {
                    var xsect = FSharpList<Value>.Empty;
                    xsect = FSharpList<Value>.Cons(Value.NewNumber(ir.UVPoint.U), xsect);
                    xsect = FSharpList<Value>.Cons(Value.NewNumber(ir.UVPoint.V), xsect);
                    xsect = FSharpList<Value>.Cons(Value.NewContainer(ir.XYZPoint), xsect);
                    xsect_results = FSharpList<Value>.Cons(Value.NewList(xsect), xsect_results);

                    pts.Add(ir.XYZPoint);
                }

            }
            results = FSharpList<Value>.Cons(Value.NewList(xsect_results), results);
            results = FSharpList<Value>.Cons(Value.NewString(result.ToString()), results);

            return Value.NewList(results);
        }
开发者ID:kyoisi,项目名称:Dynamo,代码行数:29,代码来源:dynIntersection.cs

示例13: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            //Level elements take in one double for the z elevation (height)f
            var h = (double)((FScheme.Value.Number)args[0]).Item;
            var name = ((FScheme.Value.String)args[1]).Item;

            Autodesk.Revit.DB.Level lev;

            if (this.Elements.Any())
            {
                if (dynUtils.TryGetElement(this.Elements[0], out lev))
                {
                    lev.Elevation = h;
                    lev.Name = name;
                }
                else
                {
                    lev = this.UIDocument.Document.IsFamilyDocument
                        ? this.UIDocument.Document.FamilyCreate.NewLevel(h)
                        : this.UIDocument.Document.Create.NewLevel(h);
                    lev.Name = name;
                    this.Elements[0] = lev.Id;
                }
            }
            else
            {
                lev = this.UIDocument.Document.IsFamilyDocument
                    ? this.UIDocument.Document.FamilyCreate.NewLevel(h)
                    : this.UIDocument.Document.Create.NewLevel(h);
                lev.Name = name;
                this.Elements.Add(lev.Id);
            }

            return FScheme.Value.NewContainer(lev);
        }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:35,代码来源:Level.cs

示例14: Evaluate

 public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
 {
     dynRevitSettings.ElementsContainers.Push(ElementsContainer);
     var result = base.Evaluate(args);
     dynRevitSettings.ElementsContainers.Pop();
     return result;
 }
开发者ID:hippo811028,项目名称:Dynamo,代码行数:7,代码来源:dynFunctionWithRevit.cs

示例15: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            var f = ((FScheme.Value.Function)args[0]).Item;
            var x = ((FScheme.Value.Number)args[1]).Item;
            var max_its = (int) Math.Max(1, ((FScheme.Value.Number) args[2]).Item);

            var count = 0;
            var change = 1e10;
            var max_change = 1e-5;
            var h = 1e-5;

            // use newton's method
            while (count < max_its && change > max_change)
            {
                var fx = InvokeFunction(f, x);
                var fxh = InvokeFunction(f, x + h);
                var dfx = (fxh - fx)/h;

                var x1 = x - fx/dfx;
                change = x - x1;
                x = x1;

                count++;
            }

            return FScheme.Value.NewNumber(x);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:27,代码来源:dynOptimize.cs


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