예제 #1
0
            protected override LazyItem <int> GenerateNextValue()
            {
                var currentSum = Value;
                var newOne     = new LazyValueIterator(() =>
                {
                    return(currentSum + (this.previous == null? 1: this.previous.Value));
                });

                newOne.previous = this;
                return(newOne);
            }
예제 #2
0
        public void LazyList()
        {
            var newIterator = new LazyValueIterator(() =>
            {
                return(0);
            });

            int number = 5;
            int index  = 0;

            int[] check = new [] { 0, 1, 1, 2, 3, 5, 8, 13 };
            foreach (var item in newIterator)
            {
                Assert.IsTrue(item == check[index]);
                index++;
                if (index > number)
                {
                    break;
                }
            }
            Assert.IsTrue(index > number);
        }