public static NonEmptyLazyList <Pair <A, B> > Zip <A, B>(this NonEmptyLazyList <A> list, NonEmptyLazyList <B> other) { return (from a in list from b in other select Pair.Create(a, b)); }
public static IEnumerable <A> Enumerable <A>(this NonEmptyLazyList <A> nel) { yield return(nel.Head); foreach (var a in nel.Tail.Enumerable().SelectMany(tail => tail.Enumerable())) { yield return(a); } }
public bool Eq(NonEmptyLazyList <A> t1, NonEmptyLazyList <A> t2) { return (aeq.Eq(t1.Head, t2.Head) && ((t1.Tail.IsNothing() && t2.Tail.IsNothing()) || MaybeFunctor.Instance.Map( MaybeZipable.Instance.Zip(t1.Tail, t2.Tail), p => Eq(p.Fst, p.Snd)) .ValueOr(() => false))); }
public static NonEmptyLazyList <B> Bind <A, B>(this NonEmptyLazyList <A> list, Func <A, NonEmptyLazyList <B> > f) { var ht = list.HeadTail(); return(f(ht.Fst).SemiOp(ht.Snd.Select(f).Aggregate((a, b) => a.SemiOp(b)))); }
public static NonEmptyLazyList <A> Join <A>(this NonEmptyLazyList <NonEmptyLazyList <A> > list) { return(list.Bind(a => a)); }
public static NonEmptyLazyList <C> SelectMany <A, B, C>(this NonEmptyLazyList <A> m, Func <A, NonEmptyLazyList <B> > k, Func <A, B, C> f) { return(m.Bind(a => k(a).Bind <B, C>(b => f(a, b).PureNonEmptyLazyList()))); }
public static NonEmptyLazyList <B> Extend <A, B>(this NonEmptyLazyList <A> list, Func <NonEmptyLazyList <A>, B> f) { return(f(list).PureNonEmptyLazyList()); }
public static NonEmptyLazyList <B> Ap <A, B>(this NonEmptyLazyList <Func <A, B> > f, NonEmptyLazyList <A> arg) { return(f.Bind(arg.Map)); }
public static NonEmptyLazyList <A> SemiOp <A>(this NonEmptyLazyList <A> nel, NonEmptyLazyList <A> other) { return(Semigroup.NonEmptyLazyList <A>().Op(nel, other)); }
public DynamicFunctor(NonEmptyLazyList <A> list) { this.list = list; }
public static IFunctor <A> Dynamic <A>(NonEmptyLazyList <A> list) { return(new DynamicFunctor <A>(list)); }
public NonEmptyLazyList <B> Map <A, B>(NonEmptyLazyList <A> list, Func <A, B> f) { var ht = list.HeadTail(); return(f(ht.Fst).Cons(ht.Snd.Select(f))); }
public static Maybe <Pair <A, IEnumerable <A> > > Uncons <A>(this NonEmptyLazyList <A> list) { return(Maybe.Just(list.HeadTail())); }
public static NonEmptyLazyList <B> Map <A, B>(this NonEmptyLazyList <A> list, Func <A, B> f) { return(NonEmptyLazyListFunctor.Instance.Map(list, f)); }
protected override IEnumerable <T> Create <T>(IEnumerable <T> input) { return(input.NonEmptyLazyList().ValueOr(() => NonEmptyLazyList.Single(default(T))).Enumerable()); }
public static A Extract <A>(this NonEmptyLazyList <A> list) { return(list.Head); }
public static NonEmptyLazyList <A> PureNonEmptyLazyList <A>(this A value) { return(NonEmptyLazyList.Single(value)); }
public static NonEmptyLazyList <B> Select <A, B>(this NonEmptyLazyList <A> m, Func <A, B> f) { return(m.Map(f)); }
public static NonEmptyLazyList <B> Ap <A, B>(this Func <A, B> f, NonEmptyLazyList <A> arg) { return(arg.Map(f)); }
public static NonEmptyLazyList <B> SelectMany <A, B>(this NonEmptyLazyList <A> m, Func <A, NonEmptyLazyList <B> > k) { return(m.Bind(k)); }