public void LookupSingleTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;

            list = AltBinaryRandomAccessList <string> .Cons("A", list);

            Assert.AreEqual("A", AltBinaryRandomAccessList <string> .Lookup(0, list));
        }
        public void ConsEmptyTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;

            list = AltBinaryRandomAccessList <string> .Cons("A", list);

            Assert.AreEqual("[One: A, {}]", DumpTree(list));
        }
        public void IsEmptyTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;

            Assert.IsTrue(AltBinaryRandomAccessList <string> .IsEmpty(list));
            list = AltBinaryRandomAccessList <string> .Cons("A", list);

            Assert.IsFalse(AltBinaryRandomAccessList <string> .IsEmpty(list));
        }
        public void Test1()
        {
            var list = AltBinaryRandomAccessList <int> .Empty;

            for (var i = 0; i < 11; i++)
            {
                list = AltBinaryRandomAccessList <int> .Cons(i, list);
            }
            Assert.AreEqual("[One: 10, {(9, 8), (7, 6), (5, 4), (3, 2), (1, 0)}]", DumpTree(list));
        }
        public void ConsOneTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;

            list = AltBinaryRandomAccessList <string> .Cons("A", list);

            list = AltBinaryRandomAccessList <string> .Cons("B", list);

            Assert.AreEqual("[Zero: {(B, A)}]", DumpTree(list));
        }
        public void DumpEvenTree()
        {
            const string data = "a b c d";
            var          tree = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            Assert.AreEqual("[Zero: {(d, c), (b, a)}]", DumpTree(tree));
        }
        public void RoseTest()
        {
            const string data = "What's in a name? That which we call a rose by any other name would smell as sweet.";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            Assert.AreEqual("[Zero: {(sweet., as), (smell, would), (name, other), (any, by), (rose, a), (call, we), (which, That), (name?, a), (in, What's)}]", DumpTree(list));
            Assert.AreEqual("sweet.", AltBinaryRandomAccessList <string> .Lookup(0, list));
            Assert.AreEqual("What's", AltBinaryRandomAccessList <string> .Lookup(17, list));
        }
        public void FUpdateZeroOddTest()
        {
            const string data = "How now, brown cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            list = AltBinaryRandomAccessList <string> .Fupdate(value => value + "-" + value, 1, list);

            Assert.AreEqual("[Zero: {(cow?, brown-brown), (now,, How)}]", DumpTree(list));
            Assert.AreEqual("brown-brown", AltBinaryRandomAccessList <string> .Lookup(1, list));
        }
        public void FUpdateOneTest()
        {
            const string data = "How now, cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            list = AltBinaryRandomAccessList <string> .Fupdate(value => value + "-" + value, 1, list);

            Assert.AreEqual("[One: cow?, {(now,-now,, How)}]", DumpTree(list));
            Assert.AreEqual("now,-now,", AltBinaryRandomAccessList <string> .Lookup(1, list));
        }
        public void UpdateTest()
        {
            const string data = "How now, brown cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            list = AltBinaryRandomAccessList <string> .Update(1, "green", list);

            Assert.AreEqual("[Zero: {(cow?, green), (now,, How)}]", DumpTree(list));
            Assert.AreEqual("green", AltBinaryRandomAccessList <string> .Lookup(1, list));
        }
        public void TailTest()
        {
            const string data = "How now, brown cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));
            var          tail = AltBinaryRandomAccessList <string> .Tail(list);

            Assert.AreEqual("[One: brown, {(now,, How)}]", DumpTree(tail));
        }
        public void HeadTest()
        {
            const string data = "How now, brown cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            Assert.AreEqual("cow?", AltBinaryRandomAccessList <string> .Head(list));
        }