Exemplo n.º 1
0
        public static IEnumerable <TResult> ZipAny <T1, T2, TResult>(
            this IEnumerable <T1> first,
            IEnumerable <T2> second,
            Func <T1, T2, Maybe <TResult> > resultSelector)
        {
#if true || PLAIN_LINQ
            return(Maybe.CollectAny(first.Zip(second, resultSelector)));
#else
            return(from x in first.Zip(second, resultSelector)
                   where x.IsSome
                   select x.Value);
#endif
        }
Exemplo n.º 2
0
        public static IEnumerable <TResult> SelectAny <TSource, TResult>(
            this IEnumerable <TSource> source,
            Func <TSource, Maybe <TResult> > selector)
        {
#if PLAIN_LINQ
            return(Maybe.CollectAny(source.Select(selector)));
#else
            if (selector is null)
            {
                throw new Anexn(nameof(selector));
            }

            return(from x in source
                   let m = selector(x)
                           where m.IsSome
                           select m.Value);
#endif
        }