Пример #1
0
        }; //TODO


        public static bool Execute(out Types.Transaction transaction, ContractArgs contractArgs, bool isWitness)
        {
            try
            {
                var fileName     = HttpServerUtility.UrlTokenEncode(contractArgs.ContractHash);
                var contractCode = File.ReadAllText(Path.Combine(_OutputPath, Path.ChangeExtension(fileName, ".fs")));
                var func         = ContractExamples.Execution.compileQuotedContract(contractCode);

                var result = func.Invoke(new Tuple <byte[], byte[], FSharpFunc <Types.Outpoint, FSharpOption <Types.Output> > >(
                                             contractArgs.Message,
                                             contractArgs.ContractHash,
                                             FSharpFunc <Types.Outpoint, FSharpOption <Types.Output> > .FromConverter(t => contractArgs.tryFindUTXOFunc(t))));

                var txSkeleton = result as Tuple <FSharpList <Types.Outpoint>, FSharpList <Types.Output>, byte[]>;

                transaction = txSkeleton == null || txSkeleton.Item2.Count() == 0 ? null :
                              new Types.Transaction(
                    Tests.tx.version,
                    txSkeleton.Item1,
                    ListModule.OfSeq <byte[]>(isWitness ? new byte[][] { contractArgs.Message } : new byte[][] { }),
                    txSkeleton.Item2,
                    FSharpOption <Types.ExtendedContract> .None                           //TODO: get from txSkeleton.Item3
                    );

                return(true);
            }
            catch (Exception e)
            {
                BlockChainTrace.Error("Error executing contract", e);
            }

            transaction = null;

            return(false);
        }
        public void Ai_Or_User_Does_Not_Move()
        {
            var ticTacToeBox = new List <string>()
            {
                "x", "@", "x",
                "x", "@", "x",
                "@", "x", "@"
            };

            var user = new User();
            var aI   = new Ai();
            var game = new TicTacToeGame(
                user,
                aI,
                new GameSettings.gameSetting(3, "@", "x"
                                             , (int)PlayerValues.playerVals.Human
                                             , false, false, false)
                );

            var outputBox = game.Play(new TicTacToeBoxClass.TicTacToeBox(
                                          ListModule.OfSeq(ticTacToeBox)), 1);

            for (var i = 0; i < outputBox.cellCount(); i++)
            {
                Assert.Equal(ticTacToeBox[i], outputBox.getGlyphAtLocation(i));
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("This small project demonstrates interoperability between F# and C#.");
            Console.WriteLine();

            Console.WriteLine("Creating a new shift register, which is type defined in an F# project.");
            var shiftReg = new ShiftRegister(0x0123456789ABCDEF, 64);

            Console.WriteLine($"Calling the ShiftRegister's ToString() -> '{shiftReg}'");
            Console.WriteLine();

            Console.WriteLine("Lists have some interesting interoperability.");

            var taps = ListModule.OfSeq(new List <int>()
            {
                3, 5
            });
            var xorLFSR = new ExclusiveOrLFSR(1, taps);

            var set       = new HashSet <BigInteger>();
            var iteration = 0;

            Console.WriteLine("Looping through XOR LFSR until a duplicate value is found...");
            while (!set.Contains(xorLFSR.State))
            {
                iteration++;
                set.Add(xorLFSR.State);
                Console.WriteLine($"Iteration #{iteration}: {xorLFSR.State}");
                xorLFSR.Shift();
            }
        }
        public void Tie_Wins()
        {
            var ticTacToeBox = new List <string>()
            {
                "x", "@", "x",
                "x", "@", "x",
                "@", "x", "@"
            };

            var user = new User();
            var aI   = new Ai();
            var game = new TicTacToeGame(
                user,
                aI,
                new GameSettings.gameSetting(3, "@", "x"
                                             , (int)PlayerValues.playerVals.Human
                                             , false, false, false)
                );

            var outputBox = game.CheckForWinner(
                new TicTacToeBoxClass.TicTacToeBox(
                    ListModule.OfSeq(ticTacToeBox)));

            Assert.True(outputBox);
        }
Пример #5
0
        public void SerializationTests_FSharp_Collections()
        {
            var elements = new List <int>()
            {
                0, 1, 2
            };

            var mapElements = new List <Tuple <int, string> >()
            {
                new Tuple <int, string>(0, "zero"),
                new Tuple <int, string>(1, "one")
            };

            // F# list
            RoundtripSerializationTest(ListModule.Empty <int>());
            RoundtripSerializationTest(ListModule.OfSeq(elements));

            // F# set
            RoundtripSerializationTest(SetModule.Empty <int>());
            RoundtripSerializationTest(SetModule.OfSeq(elements));

            // F# map
            RoundtripSerializationTest(MapModule.OfSeq(new List <Tuple <int, string> >()));
            RoundtripSerializationTest(MapModule.OfSeq(mapElements));
        }
Пример #6
0
        public void ClearBoardTest()
        {
            var colors = new List <Colors>();

            for (int i = 0; i < GameConstants.WellCount; i++)
            {
                if (i < 10)
                {
                    colors.Add(Colors.BLUE);
                }
                else if (i >= 30 && i < 40)
                {
                    colors.Add(Colors.BLUE);
                }
                else
                {
                    colors.Add(Colors.Empty);
                }
            }
            var fList     = ListModule.OfSeq(colors);
            var clearRows = Board.getClearRows(fList);

            Assert.AreEqual(0, clearRows[0]);
            Assert.AreEqual(30, clearRows[1]);
            var newBoard = Board.getClearBoard(fList, clearRows, 0).ToList();

            Assert.IsFalse(newBoard.Any(a => a != Colors.Empty));
        }
Пример #7
0
        static void Main(string[] args)
        {
            initBoard();

            //loop over the number of properties
            //every property should not be equal for all row, column and diagonal

            for (int k = 0; k < 4; k++)
            {
                GenerateRowRules(k);
                GenerateColumnRules(k);
                GenerateDiagonalRules(k);
            }

            //add the rules that not all stones should be the same
            NotAllTheSame();

            //combine all rules
            FSharpList <CNFify.Term> FSharpAllPropositions = ListModule.OfSeq(AllPropositions);

            CNFify.Term all = CNFify.createAndClauseFromList(FSharpAllPropositions);

            var dimacs = CNFify.makeDimacs(all);

            using (System.IO.StreamWriter file = new System.IO.StreamWriter("..\\..\\..\\Minisat\\input"))
            {
                file.WriteLine(dimacs);
            }
        }
Пример #8
0
        public MainViewModel()
        {
            Model = new PlotModel();

            var profile = new Profile(Gender.Male, 80);

            var start = DateTime.Now.AddHours(-5);

            var drinks = new List <DrinkEntry> {
                new DrinkEntry(DrinkType.Beer, start.AddMinutes(5), 330.0, 4.6),
                new DrinkEntry(DrinkType.Beer, start.AddMinutes(25), 330.0, 4.6),
                new DrinkEntry(DrinkType.Beer, start.AddMinutes(50), 330.0, 4.6),
                new DrinkEntry(DrinkType.Beer, start.AddMinutes(75), 330.0, 4.6),
                new DrinkEntry(DrinkType.Spirits, start.AddMinutes(90), 40.0, 40.0)
            };

            var result = Library.Promillekoll.calculateAlcoholLevelOverTime(profile, ListModule.OfSeq(drinks));
            var series = new LineSeries("Alcohol Level");

            foreach (var entry in result)
            {
                var minutesSinceFirstDrink = entry.Item1.Subtract(start).TotalMinutes;
                series.Points.Add(new DataPoint(minutesSinceFirstDrink, entry.Item2));
            }
            Model.Series.Add(series);
        }
Пример #9
0
 public void Start()
 {
     _Log.Info("WebServer is starting...");
     try
     {
         // TODO Build optional SSL support with certificates
         SuaveHttp.Protocol protocol = SuaveHttp.Protocol.HTTP;
         FSharpList <SuaveHttp.HttpBinding> bindings = ListModule.OfSeq(_ListenAddresses.Select(ep => new SuaveHttp.HttpBinding(protocol, new Suave.Sockets.SocketBinding(ep.Address, (ushort)ep.Port))));
         var suaveConfig = SuaveWeb.defaultConfig.withCancellationToken(_CancellationTokenSource.Token).withBindings(bindings);
         GlobalHost.DependencyResolver.Register(typeof(RemoteHub), () => new RemoteHub(_RemoteControlService, this));
         AppBootstrapper bootstrapper = new AppBootstrapper(_RemoteControlService);
         NancyOptions    nancyOptions = new NancyOptions();
         nancyOptions.Bootstrapper = bootstrapper;
         AppBuilder appBuilder = new AppBuilder();
         appBuilder.MapSignalR();
         appBuilder.UseNancy(nancyOptions);
         var owin        = appBuilder.Build();
         var app         = Suave.Owin.OwinAppModule.OfAppFunc("", owin);
         var startAction = SuaveWeb.startWebServerAsync(suaveConfig, app);
         FSharpAsync.Start(startAction.Item2, FSharpOption <CancellationToken> .Some(_CancellationTokenSource.Token));
         FSharpAsync.StartAsTask(startAction.Item1, FSharpOption <TaskCreationOptions> .Some(TaskCreationOptions.None), FSharpOption <CancellationToken> .None).ContinueWith((started) =>
         {
             _Log.Info("WebServer is running.");
             Status = ServerStatus.Ready;
         });
     }
     catch (Exception ex)
     {
         _Log.Error(string.Format("Failed to start web server: {0}", ex.Message), ex);
         Status = ServerStatus.Stopped;
         Error  = ex;
     }
 }
Пример #10
0
        public void ParseKeyRemapOptions2()
        {
            var tuple = CommandParseUtil.ParseKeyRemapOptions(ListModule.OfSeq("a"));

            Assert.AreEqual(KeyRemapOptions.None, tuple.Item2);
            Assert.AreEqual('a', tuple.Item1.First());
        }
Пример #11
0
        public IsTxOrphanResult IsOrphanTx(TransactionContext dbTx, Types.Transaction tx, bool isBlock, out TransactionValidation.PointedTransaction ptx)
        {
            var outputs = new List <Types.Output>();

            ptx = null;

            foreach (Types.Outpoint input in tx.inputs)
            {
                bool valid;
                var  output = GetUTXO(input, dbTx, isBlock, out valid);

                if (!valid)
                {
                    return(IsTxOrphanResult.Invalid);
                }
                if (output != null)
                {
                    outputs.Add(output);
                }
                else
                {
                    return(IsTxOrphanResult.Orphan);
                }
            }

            ptx = TransactionValidation.toPointedTransaction(
                tx,
                ListModule.OfSeq(outputs)
                );

            return(IsTxOrphanResult.NotOrphan);
        }
Пример #12
0
 private FScopeConfirmation CreateScopeConfirmation(ITimeRange timeRange, long setStartAt)
 {
     return(new FScopeConfirmation(ListModule.OfSeq(new List <ITimeRange>()
     {
         timeRange
     }), setStartAt));
 }
        public void RandomWithChain()
        {
            string             man      = "A1";
            SortedSet <string> expected = new SortedSet <string> {
                "B1", "B2", "C1", "D1"
            };
            List <Tuple <string, string> > CSarpPairs = new List <Tuple <string, string> >
            {
                new Tuple <string, string>("A1", "B1"),
                new Tuple <string, string>("A1", "B2"),
                new Tuple <string, string>("B2", "C1"),
                new Tuple <string, string>("C1", "D1"),

                new Tuple <string, string>("A2", "B3"),

                new Tuple <string, string>("A2", "B4"),

                new Tuple <string, string>("C2", "D2"),

                new Tuple <string, string>("A3", "B5")
            };
            FSharpList <Tuple <string, string> > FSarpPairs = ListModule.OfSeq(CSarpPairs);

            string             result           = printChildren(FSarpPairs, man, "");
            SortedSet <string> resultCollection = Functions.ConvertToSet(result);

            CollectionAssert.AreEqual(expected, resultCollection);
        }
Пример #14
0
        public void Problem1()
        {
            long result   = ProjectEuler001_100.Problem001(1000, ListModule.OfSeq(new int[] { 3, 5 }));
            long expected = 233168L;

            Assert.AreEqual(expected, result);
        }
Пример #15
0
        public override int UpdateRom(int Seed, ref byte[] RomData, bool GenerateSpoiler)
        {
            ApplyPatches(ref RomData);

            SetupSeed(ref Seed, RomData);

            var ItemLocationList = GetItemLocations(Seed);

            if (GenerateSpoiler)
            {
                WriteProgressionLog(Seed, ItemLocationList);
                WriteSpoilerLog(Seed, ItemLocationList);
            }

            if (RomData != null)
            {
                var sortedItems = ItemLocationList.Where(p => p.Item.Class == Types.ItemClass.Major &&
                                                         p.Item.Type != Types.ItemType.ETank && p.Item.Type != Types.ItemType.Reserve).OrderBy(p => p.Item.Type);

                _ = Randomizer.writeRomSpoiler(RomData, ListModule.OfSeq(sortedItems), 0x2f5240);
                _ = Randomizer.writeLocations(RomData, ListModule.OfSeq(ItemLocationList));
            }

            return(Seed);
        }
Пример #16
0
                      List <Syntax.VarDecl>, List <Syntax.Stmt> > IncludeSurroundingScopes(string fName)
        {
            var typLst = new List <Syntax.Type>();
            var expLst = new List <Syntax.Expr>();
            var vdLst  = new List <Syntax.VarDecl>();
            //var asgnLst = new List<Syntax.Stmt>();
            var restoreLst = new List <Syntax.Stmt>();
            int i          = 0;

            foreach (var tbl in tbls)
            {
                foreach (var v in tbl.Item2)
                {
                    var name = tbl.Item1 + '_' + v.Key;
                    typLst.Add(v.Value);
                    expLst.Add(Syntax.Expr.NewVar(name));
                    vdLst.Add(new Syntax.VarDecl(name, v.Value));
                    //asgnLst.Add(Syntax.Stmt.NewAssign(
                    //Syntax.Lval.NewDot(Syntax.Lval.NewVar(fName + "_env"), i),
                    //Syntax.Expr.NewVar(name)));
                    restoreLst.Add(Syntax.Stmt.NewAssign(Syntax.Lval.NewVar(name),
                                                         Syntax.Expr.NewDot(Syntax.Expr.NewVar(fName + "_env"), i)));
                    i++;
                }
            }

            var tupType = Syntax.Type.NewTuple(ListModule.OfSeq(typLst))
                          as Syntax.Type.Tuple;
            var tupExpr = Syntax.Expr.NewTuple(ListModule.OfSeq(expLst))
                          as Syntax.Expr.Tuple;

            return(new Tuple <Syntax.Type.Tuple, Syntax.Expr.Tuple,
                              List <Syntax.VarDecl>, List <Syntax.Stmt> >
                       (tupType, tupExpr, vdLst, restoreLst));
        }
Пример #17
0
        public static Types.Block AddTx(this Types.Block bk, Types.Transaction tx)
        {
            //var nonce = new byte[10];
            //new Random().NextBytes(nonce);
            var nonce = new byte[] { };

            var header = new Types.BlockHeader(
                0,
                new byte[] { },
                bk.header.blockNumber + 1,
                new byte[] { },
                new byte[] { },
                new byte[] { },
                ListModule.OfSeq <byte[]>(new List <byte[]>()),
                DateTime.Now.ToUniversalTime().Ticks,
                0,
                nonce
                );

            var txs = bk.transactions.ToList();

            txs.Add(tx);

            return(new Types.Block(bk.header, ListModule.OfSeq <Types.Transaction>(txs)));
        }
Пример #18
0
        public static Types.Block Child(this Types.Block bk)
        {
            var nonce = new byte[10];

            new Random().NextBytes(nonce);
            //var nonce = new byte[] { };

            var header = new Types.BlockHeader(
                0,
                Merkle.blockHeaderHasher.Invoke(bk.header),
                bk.header.blockNumber + 1,
                new byte[] { },
                new byte[] { },
                new byte[] { },
                ListModule.OfSeq <byte[]>(new List <byte[]>()),
                DateTime.Now.ToUniversalTime().Ticks,
                0,
                nonce
                );

            var txs = new List <Types.Transaction>();

            txs.Add(Utils.GetCoinbaseTx(bk.header.blockNumber + 1));

            return(new Types.Block(header, ListModule.OfSeq(txs)));
        }
Пример #19
0
        public static Types.Block GetGenesisBlock()
        {
            var nonce = new byte[10];

            new Random().NextBytes(nonce);

            var header = new Types.BlockHeader(
                0,
                new byte[] { },
                0,
                new byte[] { },
                new byte[] { },
                new byte[] { },
                ListModule.OfSeq <byte[]>(new List <byte[]>()),
                DateTime.Now.ToUniversalTime().Ticks,
                0,
                nonce
                );

            var txs = new List <Types.Transaction>();

            txs.Add(GetTx());

            return(new Types.Block(header, ListModule.OfSeq(txs)));
        }
Пример #20
0
            Tuple <T, FSharpList <TEvent> > decide_(TState state)
            {
                var a = new Accumulator <TEvent, TState>(_fold, state);
                var r = decide(a);

                return(Tuple.Create(r, ListModule.OfSeq(a.Accumulated)));
            }
Пример #21
0
 public void Reset()
 {
     _layoutList = _windowManager
                   .EnumerateLayouts()
                   .Select(layout =>
     {
         var layoutItem = new LayoutItem(layout);
         var down       = ListModule.OfSeq(new List <int> {
             2, 3
         });
         var stack    = new Kolonnade.Stack <int>(1, FSharpList <int> .Empty, down);
         var iconArea = new Rectangle(0, 0, 32, 32);
         foreach (var(windowNumber, area) in layout.DoLayout(stack, iconArea))
         {
             if (windowNumber == 1)
             {
                 layoutItem.MainWindow = area;
             }
             else if (windowNumber == 2)
             {
                 layoutItem.SecondWindow = area;
             }
             else if (windowNumber == 3)
             {
                 layoutItem.ThirdWindow = area;
             }
         }
         return(layoutItem);
     })
                   .ToList();
 }
Пример #22
0
        static void Main(string[] args)
        {
            var myObject = new MyObject(
                100,
                SingleCaseUnion.NewSingleCaseUnion(12345),
                DiscriminatedUnion.NewCase1DU(111, "aaa"),
                ListModule.OfSeq(new[] { 0, 1, 2, 3, 4, 5 }),
                MapModule.OfSeq(new[] { Tuple.Create("One", 1), Tuple.Create("Two", 2) }),
                Tuple.Create("Hello", "F# fans"),
                FSharpOption <string> .Some("Option1")
                );

            //var converters = new JsonConverter[0];
            var converters = new JsonConverter[] { new UnionConverter() };

            // Test a single serialize and deserialize
            var json        = JsonConvert.SerializeObject(myObject, converters);
            var myNewObject = JsonConvert.DeserializeObject <MyObject>(json, converters);

            Console.WriteLine("Writing {0}", json);
            //Console.WriteLine("Objects are the same {0}", (myObject == myNewObject));

            var count = 10000;

            Duration(() => SerializeLoad(false, count, myObject, converters), count, "Serialize Default");
            Duration(() => DeserializeLoad(false, count, myObject, converters), count, "Deserialize Default");
            Duration(() => SerializeLoad(true, count, myObject, converters), count, "Serialize Custom");
            Duration(() => DeserializeLoad(true, count, myObject, converters), count, "Deserialize Custom");
        }
Пример #23
0
        public void ClearBoardTest2()
        {
            var colors = new List <Colors>();

            for (int i = 0; i < GameConstants.WellCount; i++)
            {
                if (i < 10)
                {
                    colors.Add(Colors.BLUE);
                }
                else if (i >= 30 && i < 40)
                {
                    colors.Add(Colors.BLUE);
                }
                else
                {
                    colors.Add(Colors.Empty);
                }
            }
            var fList     = ListModule.OfSeq(colors);
            var gameState = GameStateFactory.GetGameState_GivenBoard(new System.Random(), fList);
            var engine    = new Engine(0, gameState);

            engine.tick();
            var gs        = engine.ViewGameState();
            var clearRows = Board.getClearRows(gs.Board);

            Assert.IsTrue(!clearRows.Any());
        }
Пример #24
0
        void DispatchBlock()
        {
            try
            {
                _Hasher.Pause("dispatching block");

                MinerTrace.Information($"dispatching block with {_ValidatedTxs.Count()} txs");

                var txs = FSharpList <Types.Transaction> .Cons(_Coinbase, ListModule.OfSeq(_ValidatedTxs.Select(TransactionValidation.unpoint)));

                var block = new Types.Block(_Header, txs);


                var result = new HandleBlockAction(block).Publish().Result.BkResultEnum;

                if (result == BlockVerificationHelper.BkResultEnum.Accepted)
                {
                    if (OnMined != null)
                    {
                        OnMined(block);
                    }
                }
                else
                {
                    Reset();
                }

                MinerTrace.Information($"  block {block.header.blockNumber} is " + result);
            } catch (Exception e)
            {
                MinerTrace.Error("Dispatch block exception", e);
            }
        }
Пример #25
0
        public void OnFinished(string value1, TestResult value2)
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.CursorVisible = true;

            switch (value2)
            {
            case TestResult.False @false:
                var original = @false.Item2.Select(value => value is IFormatted formatted ? Format.Wrap(formatted, Format.Types.Summary) : value);
                var shrunk   = @false.Item3.Select(value => value is IFormatted formatted ? Format.Wrap(formatted, Format.Types.Detailed) : value);
                var wrapped  = TestResult.NewFalse(@false.Item1, ListModule.OfSeq(original), ListModule.OfSeq(shrunk), @false.Item4, @false.Item5);
                FsCheck.Runner.consoleRunner.OnFinished(value1, wrapped);
                if (_throw)
                {
                    throw new Exception();
                }
                break;

            default:
                FsCheck.Runner.consoleRunner.OnFinished(value1, value2);
                break;
            }

            Console.WriteLine();
            Console.WriteLine($"Done in {_watch.Elapsed}");
            Console.WriteLine();
        }
        public void User_Moves()
        {
            var user = new User();
            var correctTicTacToeBox = new TicTacToeBoxClass.TicTacToeBox(
                ListModule.OfSeq(new List <string>()
            {
                "x",
                "-2-",
                "-3-",
                "-4-",
                "-5-",
                "-6-",
                "-7-",
                "-8-",
                "-9-"
            }));
            var ticTacToeBox = user.Move(
                new TicTacToeBoxClass.TicTacToeBox(Game.makeTicTacToeBox(3))
                , 1, "x", "@");

            for (var i = 0; i < correctTicTacToeBox.cellCount(); i++)
            {
                Assert.Equal(correctTicTacToeBox.getGlyphAtLocation(i)
                             , ticTacToeBox.getGlyphAtLocation(i));
            }
        }
Пример #27
0
        void InitPaginator()
        {
            var dbData = MOCK_InitializeData();

            DbData = dbData;
            var currentPage          = new IntMore0Less65535Exclsv(1);
            var itemsPerPageList     = MOCK_InitializeItemsPerPage().ToArray();
            var pagesToSkipList      = MOCK_InitializeItemsPagesToSkip().ToArray();
            var defauleSelectedIndex = 0;

            ComboBoxItemsPerPage.ItemsSource   = itemsPerPageList;
            ComboBoxItemsPerPage.SelectedIndex = defauleSelectedIndex;

            ComboBoxPagesToSkip.ItemsSource   = pagesToSkipList;
            ComboBoxPagesToSkip.SelectedIndex = defauleSelectedIndex;
            FSharpList <int> niceSharpList = ListModule.OfSeq(dbData);

            PaginatorCurrentState = Init(
                currentPage,
                itemsPerPageList[defauleSelectedIndex],
                pagesToSkipList[defauleSelectedIndex],
                Context.GetTotalNumberOfItemsInDB(dbData)
                );

            RenderPaginator(PaginatorCurrentState);
        }
Пример #28
0
        /// <summary>
        /// Change a C# parse tree to a F# AST
        /// </summary>
        public static FSharpTransform.Formula CreateFSharpTree(this ParseTreeNode input)
        {
            if (input.IsParentheses())
            {
                return(FSharpTransform.Formula.NewFunction("", ListModule.OfSeq(new [] { CreateFSharpTree(input.ChildNodes[0]) })));
            }

            input = input.SkipToRelevant();

            switch (input.Type())
            {
            case GrammarNames.FunctionCall:
            case GrammarNames.ReferenceFunctionCall:
            case GrammarNames.UDFunctionCall:
                var fname = input.GetFunction() + (input.IsNamedFunction()?"(":"");
                var args  = ListModule.OfSeq(input.GetFunctionArguments().Select(CreateFSharpTree));
                // Check for range
                if (fname == ":")
                {
                    return(makeFSharpRange(input));
                }
                return(FSharpTransform.makeFormula(fname, args));

            case GrammarNames.Reference:
                // ignore prefix
                return(CreateFSharpTree(input.ChildNodes.Count == 1 ? input.ChildNodes[0] : input.ChildNodes[1]));

            case GrammarNames.Cell:
                var L = new Location(input.Print());
                return(FSharpTransform.makeSuperCell(FSharpTransform.makeCell(L.Column, L.Row)));

            case GrammarNames.NamedRange:
                return(FSharpTransform.makeNamedRange(input.Print()));

            case TransformationRuleGrammar.Names.DynamicCell:
                //get variables from dynamic cell
                return(FSharpTransform.makeSuperCell(GetDynamicCell(input)));

            case TransformationRuleGrammar.Names.DynamicRange:
                var letter = input          // DynamicRange
                             .ChildNodes[0] // LowLetter
                             .Token.ValueString[0];
                return(FSharpTransform.makeDRange(letter));

            case GrammarNames.Constant:
            case GrammarNames.Number:
            case GrammarNames.Text:
            case GrammarNames.Bool:
            case GrammarNames.Error:
            case GrammarNames.RefError:
                return(FSharpTransform.makeConstant(input.Print()));

            case TransformationRuleGrammar.Names.DynamicConstant:
                return(FSharpTransform.makeDArgument(input.ChildNodes[0].Token.ValueString[1]));

            default:
                throw new ArgumentException($"Can't convert node type {input.Type()}", nameof(input));
            }
        }
Пример #29
0
        public CouchUrl Filter(CouchFilter f)
        {
            var fl = ListModule.OfSeq(new CouchFilter[] { f });

            fl = ListModule.Append <CouchFilter>(this.filters, fl);

            return(Create(this.couchRepo, this.path, this.queryString, fl));
        }
Пример #30
0
        public decimal TestScatterPayout(string wheelString, string position)
        {
            var wheel  = Encoding(wheelString.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray());
            var result = Slot.Games.Wolves.Payout.payScatter(1, 1, ListModule.OfSeq(wheel));

            Assert.AreEqual(result.WinPositions.Any() ? string.Join(",", result.WinPositions.First().RowPositions) : "", position);
            return(result.Payable);
        }