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)); }
/// <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()));
/// <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()));
/// <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()));
public X combine(params X[] values) => combine(Seq.make(values));
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);
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);
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));
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));
public Seq <Choice> Execute(Choice s0) => Seq.make(_Execute(s0));