示例#1
0
 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));
 }
示例#2
0
        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);
            }
        }
示例#3
0
 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)));
 }
示例#4
0
文件: Bind.cs 项目: jedahu/Jib
        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))));
        }
示例#5
0
文件: Bind.cs 项目: jedahu/Jib
 public static NonEmptyLazyList <A> Join <A>(this NonEmptyLazyList <NonEmptyLazyList <A> > list)
 {
     return(list.Bind(a => a));
 }
示例#6
0
 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())));
 }
示例#7
0
 public static NonEmptyLazyList <B> Extend <A, B>(this NonEmptyLazyList <A> list, Func <NonEmptyLazyList <A>, B> f)
 {
     return(f(list).PureNonEmptyLazyList());
 }
示例#8
0
 public static NonEmptyLazyList <B> Ap <A, B>(this NonEmptyLazyList <Func <A, B> > f, NonEmptyLazyList <A> arg)
 {
     return(f.Bind(arg.Map));
 }
示例#9
0
文件: Semigroup.cs 项目: jedahu/Jib
 public static NonEmptyLazyList <A> SemiOp <A>(this NonEmptyLazyList <A> nel, NonEmptyLazyList <A> other)
 {
     return(Semigroup.NonEmptyLazyList <A>().Op(nel, other));
 }
示例#10
0
文件: Functor.cs 项目: jedahu/Jib
 public DynamicFunctor(NonEmptyLazyList <A> list)
 {
     this.list = list;
 }
示例#11
0
文件: Functor.cs 项目: jedahu/Jib
 public static IFunctor <A> Dynamic <A>(NonEmptyLazyList <A> list)
 {
     return(new DynamicFunctor <A>(list));
 }
示例#12
0
文件: Functor.cs 项目: jedahu/Jib
        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)));
        }
示例#13
0
文件: Uncons.cs 项目: jedahu/Jib
 public static Maybe <Pair <A, IEnumerable <A> > > Uncons <A>(this NonEmptyLazyList <A> list)
 {
     return(Maybe.Just(list.HeadTail()));
 }
示例#14
0
文件: Functor.cs 项目: jedahu/Jib
 public static NonEmptyLazyList <B> Map <A, B>(this NonEmptyLazyList <A> list, Func <A, B> f)
 {
     return(NonEmptyLazyListFunctor.Instance.Map(list, f));
 }
示例#15
0
 protected override IEnumerable <T> Create <T>(IEnumerable <T> input)
 {
     return(input.NonEmptyLazyList().ValueOr(() => NonEmptyLazyList.Single(default(T))).Enumerable());
 }
示例#16
0
 public static A Extract <A>(this NonEmptyLazyList <A> list)
 {
     return(list.Head);
 }
示例#17
0
 public static NonEmptyLazyList <A> PureNonEmptyLazyList <A>(this A value)
 {
     return(NonEmptyLazyList.Single(value));
 }
示例#18
0
 public static NonEmptyLazyList <B> Select <A, B>(this NonEmptyLazyList <A> m, Func <A, B> f)
 {
     return(m.Map(f));
 }
示例#19
0
 public static NonEmptyLazyList <B> Ap <A, B>(this Func <A, B> f, NonEmptyLazyList <A> arg)
 {
     return(arg.Map(f));
 }
示例#20
0
 public static NonEmptyLazyList <B> SelectMany <A, B>(this NonEmptyLazyList <A> m, Func <A, NonEmptyLazyList <B> > k)
 {
     return(m.Bind(k));
 }