/// <seealso cref="MonadPlus.Lift{T1, T2, T3, T4, T5, TResult}"/> public static MonadPlus <TResult> ZipWith <T1, T2, T3, T4, T5, TResult>( this MonadPlus <T1> @this, MonadPlus <T2> second, MonadPlus <T3> third, MonadPlus <T4> fourth, MonadPlus <T5> fifth, Func <T1, T2, T3, T4, T5, TResult> zipper) { Require.NotNull(@this, nameof(@this)); Require.NotNull(second, nameof(second)); Require.NotNull(third, nameof(third)); Require.NotNull(fourth, nameof(fourth)); Require.NotNull(fifth, nameof(fifth)); Require.NotNull(zipper, nameof(zipper)); // > return @this.Bind( // > arg1 => second.Bind( // > arg2 => third.Bind( // > arg3 => fourth.Bind( // > arg4 => fifth.Select( // > arg5 => zipper(arg1, arg2, arg3, arg4, arg5)))))); return(@this.Bind( arg1 => second.ZipWith( third, fourth, fifth, (arg2, arg3, arg4, arg5) => zipper(arg1, arg2, arg3, arg4, arg5)))); }
public static MonadPlus <TSource> PassBy <TSource, TOther>( this MonadPlus <TSource> @this, MonadPlus <TOther> other) { Require.NotNull(@this, nameof(@this)); return(@this.ZipWith(other, (arg, _) => arg)); }
/// <seealso cref="MonadPlus.Lift{T1, T2, T3, TResult}"/> public static MonadPlus <TResult> ZipWith <T1, T2, T3, TResult>( this MonadPlus <T1> @this, MonadPlus <T2> second, MonadPlus <T3> third, Func <T1, T2, T3, TResult> zipper) { Require.NotNull(@this, nameof(@this)); Require.NotNull(second, nameof(second)); Require.NotNull(third, nameof(third)); Require.NotNull(zipper, nameof(zipper)); // This is the same as: // > return @this.Bind( // > arg1 => second.Bind( // > arg2 => third.Select( // > arg3 => zipper(arg1, arg2, arg3)))); // but faster if ZipWith is locally shadowed. return(@this.Bind( arg1 => second.ZipWith( third, (arg2, arg3) => zipper(arg1, arg2, arg3)))); }