Exemple #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);
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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);
        }