Beispiel #1
0
        public static List <B> SelectMany <A, B>(this List <A> ps, Func <A, List <B> > f)
        {
            var b = ListBuffer <B> .Empty();

            foreach (var a in ps)
            {
                b.Append(f(a));
            }

            return(b.ToList);
        }
Beispiel #2
0
        public List <B> Extend <B>(Func <List <A>, B> f)
        {
            var b = ListBuffer <B> .Empty();

            var a = this;

            while (!a.IsEmpty)
            {
                b.Snoc(f(a));
                a = a.UnsafeTail;
            }

            return(b.ToList);
        }
Beispiel #3
0
        public List <A> Where(Func <A, bool> f)
        {
            var b = ListBuffer <A> .Empty();

            foreach (var a in this)
            {
                if (f(a))
                {
                    b.Snoc(a);
                }
            }

            return(b.ToList);
        }
        public NonEmptyList <B> Extend <B>(Func <NonEmptyList <A>, B> f)
        {
            var b = ListBuffer <B> .Empty();

            var a = tail;

            while (!a.IsEmpty)
            {
                b.Snoc(f(new NonEmptyList <A>(a.UnsafeHead, a.UnsafeTail)));
                a = a.UnsafeTail;
            }

            return(new NonEmptyList <B>(f(this), b.ToList));
        }
Beispiel #5
0
        public List <A> Append(List <A> x)
        {
            var b = ListBuffer <A> .Empty();

            foreach (var a in this)
            {
                b.Snoc(a);
            }

            foreach (var a in x)
            {
                b.Snoc(a);
            }

            return(b.ToList);
        }
Beispiel #6
0
 public ListBufferEnumerator(ListBuffer <A> o)
 {
     this.o = o.start;
 }