Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            ParseCmdsDel parseCommands = ParseCommands;
            WriteDel     writePoints   = WritePoints;

            Either <Error, string> ReadText(string path) =>
            Try(() => ReadAllText(path)).ToEither().MapLeft(Error.New);

            Either <Error, Seq <SpecificPoint> > GeneratePoints(Seq <Cmd> cmds) =>
            cmds.FoldWhile(InitialState,
                           (state, cmd) => from s in state
                           from r in InterpretCmds(s.Current, cmd)
                           select(r.Current, s.Points + r.Points),
                           state => state.IsRight)
            .Map(state => state.Points);

            var runner = Run(ReadText, parseCommands, writePoints, GeneratePoints);

            var fileNames = Seq("Instructions.txt", "Instructions0.txt", "Instructions2.txt");

            var results = fileNames.Fold(InitialRunnerState, (state, file) => state.Apply(_ => runner(file)));

            results.Match(
                Right: _ => Trace.WriteLine("Success"),
                Left: e => Trace.WriteLine(e));
        }
Exemple #2
0
 public void SetCallbacks
 (
     ReadDel ReadMemory,
     ReadDel DummyReadMemory,
     ReadDel PeekMemory,
     WriteDel WriteMemory
 )
 {
     this.ReadMemory      = ReadMemory;
     this.DummyReadMemory = DummyReadMemory;
     this.PeekMemory      = PeekMemory;
     this.WriteMemory     = WriteMemory;
 }
Exemple #3
0
		public void SetCallbacks
		(
			ReadDel ReadMemory,
			ReadDel DummyReadMemory,
			ReadDel PeekMemory,
			WriteDel WriteMemory
		)
		{
			this.ReadMemory = ReadMemory;
			this.DummyReadMemory = DummyReadMemory;
			this.PeekMemory = PeekMemory;
			this.WriteMemory = WriteMemory;
		}