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 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 Maybe <Pair <A, IEnumerable <A> > > Uncons <A>(this NonEmptyLazyList <A> list) { return(Maybe.Just(list.HeadTail())); }