Example #1
0
        public new static Choices Parse(string Value)
        {
            var parts    = Value.Bifurcate(G.Entails);
            var identity = parts.Left.Bifurcate(G.OfType);
            var choices  = Seq.make(parts.Right.Split(G.Or).Select(x => Choice.Parse(x)));

            return(new Choices(identity, choices));
        }
Example #2
0
 /// <summary>
 /// Implements a right-fold over the container
 /// </summary>
 /// <typeparam name="Y">The type of the accumulated value</typeparam>
 /// <param name="f">The accumulator</param>
 /// <param name="y0">The seed value</param>
 /// <param name="container"></param>
 /// <returns></returns>
 public Y foldr <Y>(Func <X, Y, Y> f, Y y0, CX container)
 => Seq.foldr(f, y0, Seq.make(container.Stream()));
Example #3
0
 /// <summary>
 /// Implements a left-fold over the container
 /// </summary>
 /// <typeparam name="Y">The type of the accumulated value</typeparam>
 /// <param name="f">The accumulator</param>
 /// <param name="y0">The seed value</param>
 /// <param name="container"></param>
 /// <returns></returns>
 public Y foldl <Y>(Func <Y, X, Y> f, Y y0, CX container)
 => Seq.foldl(f, y0, Seq.make(container.Stream()));
Example #4
0
 /// <summary>
 /// Folds the contained elements using required aspects of a supplied
 /// monoid
 /// </summary>
 /// <param name="m">The monoid providing the required combiner</param>
 /// <param name="container">The structure to be folded/aggregated</param>
 /// <returns></returns>
 public X fold(IMonoid <X> m, CX container)
 => Seq.foldr(m.combine, m.zero, Seq.make(container.Stream()));
Example #5
0
 public X combine(params X[] values)
 => combine(Seq.make(values));
Example #6
0
 public static Seq <X> Where <X>(this Seq <X> s, Func <X, bool> predicate)
 => Seq.make(from x in s.Stream() where predicate(x) select x);
Example #7
0
 public static Seq <Y> SelectMany <X, Y>(this Seq <X> s, Func <X, Seq <Y> > lift)
 => Seq.make(from x in s.Stream()
             from y in lift(x).Stream()
             select y);
Example #8
0
 public static Seq <Z> SelectMany <X, Y, Z>(this Seq <X> s, Func <X, Seq <Y> > lift, Func <X, Y, Z> project)
 => Seq.make(from x in s.Stream()
             from y in lift(x).Stream()
             select project(x, y));
Example #9
0
 public static Seq <Y> Select <X, Y>(this Seq <X> s, Func <X, Y> selector)
 => Seq.make(from x in s.Stream() select selector(x));
Example #10
0
 public Seq <Choice> Execute(Choice s0)
 => Seq.make(_Execute(s0));