Example #1
0
        public override Seq <A> Take(int count)
        {
            int taken = 0;
            var list  = new List <A>();

            foreach (var item in AsEnumerable())
            {
                taken++;
                list.Add(item);
                if (taken == count)
                {
                    break;
                }
            }
            return(SeqList <A> .New(list, 0, taken));
        }
Example #2
0
        public override Seq <A> TakeWhile(Func <A, int, bool> pred)
        {
            int taken = 0;
            var list  = new List <A>();

            foreach (var item in AsEnumerable())
            {
                if (!pred(item, taken))
                {
                    break;
                }
                taken++;
                list.Add(item);
                if (taken == count)
                {
                    break;
                }
            }
            return(SeqList <A> .New(list, 0, taken));
        }