Attempt to transform this Stream to the same type as the supplied Monoid, using supplied function
Then use Monoid to reduce values

@param mapper Function to transform Monad type
@param reducer Monoid to reduce values
@return Reduce result
320300
public final static <T, R> R foldMap(final Stream<T> stream, final Function<? super T, ? extends R> mapper, final Monoid<R> reducer) {
        return reducer.foldLeft(stream.map(mapper));
    }
24190
public <V> Match<V> map(Function<T, V> mapper) {
    if (matchAny) {
      return any();
    } else if (value == null) {
      return negation ? ifNotNull() : ifNull();
    } else {
      return negation ? ifNotValue(mapper.apply(value)) : ifValue(mapper.apply(value));
    }
  }
943717
@SuppressWarnings({ "unchecked", "rawtypes" })
	public <NV> Graph<K, NV, EV> mapVertices(final MapFunction<Vertex<K, VV>, NV> mapper) {

		TypeInformation<K> keyType = ((TupleTypeInfo<?>) vertices.getType()).getTypeAt(0);

		TypeInformation<NV> valueType;

		if (mapper instanceof ResultTypeQueryable) {
			valueType = ((ResultTypeQueryable) mapper).getProducedType();
		} else {
			valueType = TypeExtractor.createTypeInfo(MapFunction.class, mapper.getClass(), 1, vertices.getType(), null);
		}

		TypeInformation<Vertex<K, NV>> returnType = (TypeInformation<Vertex<K, NV>>) new TupleTypeInfo(
				Vertex.class, keyType, valueType);

		return mapVertices(mapper, returnType);
	}
1135255
private void applySerializationModifier(ObjectMapper mapper) {
		SerializerFactory factory = BeanSerializerFactory.instance
				.withSerializerModifier(new GenericSerializerModifier());
		mapper.setSerializerFactory(factory);
	}
256506
public static Mapper filterMapper(final Predicate pred){
        return new Mapper(){
            public Object map(Object a) {
                return pred.evaluate(a) ? a : null;
            }
        };
    }
991746
public static Collection map(Mapper mapper, Object o) {
        return java.util.Collections.singleton(mapper.map(o));
    }
266478
@Override
    public <T> Flowable<T> get(@Nonnull ResultSetMapper<? extends T> mapper) {
        Preconditions.checkNotNull(mapper, "mapper cannot be null");
        return update.startWithDependency(Update.<T>createReturnGeneratedKeys(update.connections,
                update.parameterGroupsToFlowable(), update.sql, mapper, true));

    }
845380
public static Mapper mapMapper(final Map map) {
        return new Mapper() {
            public Object map(final Object a) {
                return map.get(a);
            }
        };
    }
1107500
def type_map_reducer(map_: TypeMap, type_: GraphQLNamedType = None) -> TypeMap:
    """"""
    if not type_:
        return map_
    if is_wrapping_type(type_):
        return type_map_reducer(
            map_, cast(GraphQLWrappingType[GraphQLNamedType], type_).of_type
        )
    name = type_.name
    if name in map_:
        if map_[name] is not type_:
            raise TypeError(
                "Schema must contain uniquely named types but contains multiple"
                f" types named {name!r}."
            )
        return map_
    map_[name] = type_

    if is_union_type(type_):
        type_ = cast(GraphQLUnionType, type_)
        map_ = type_map_reduce(type_.types, map_)

    if is_object_type(type_):
        type_ = cast(GraphQLObjectType, type_)
        map_ = type_map_reduce(type_.interfaces, map_)

    if is_object_type(type_) or is_interface_type(type_):
        for field in cast(GraphQLInterfaceType, type_).fields.values():
            args = field.args
            if args:
                types = [arg.type for arg in args.values()]
                map_ = type_map_reduce(types, map_)
            map_ = type_map_reducer(map_, field.type)

    if is_input_object_type(type_):
        for field in cast(GraphQLInputObjectType, type_).fields.values():
            map_ = type_map_reducer(map_, field.type)

    return map_
1073978
public <U> Leader<U> map(Function<T, U> mapper) {
    return new Leader<>(mapper.apply(id), term, termStartTime);
  }
320800
@NonNull
    public static <T> Mapper<T> singletonMapper(@NonNull Binder<T, ?> binder) {
        //noinspection unchecked
        return new SingletonMapper<>((Binder<T, View>) checkNotNull(binder, "binder"));
    }
464234
public final static <R,T> R foldRightMapToType(final Stream<T> stream, final Reducer<R,T> reducer) {
        return reducer.foldMap(Streams.reverse(stream));
    }
864982
public static <T> T objectify(ObjectMapper mapper, Object source, JavaType targetType) {
        try {
            return mapper.readValue(mapper.writeValueAsBytes(source), targetType);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
435846
public static <T, R> Map<R, T> mapBy(Stream<T> stream,
            Function<T, R> classifier) {
        return stream
                .collect(toMap(classifier, identity(), (o, o2) -> o2));
    }
725055
public static <K, I, O, A> StreamReducerSimple<K, I, O, A> create(Function<I, K> keyFunction,
			Comparator<K> keyComparator,
			Reducer<K, I, O, A> reducer) {
		return new StreamReducerSimple<>(keyFunction, keyComparator, reducer);
	}
1247253
function reducer(props, map, key) {
  return Object.assign({}, map, {
    [key]: props[key],
  });
}
448066
@Override
	@SuppressWarnings("unchecked")
	protected GroupReduceOperatorBase<?, OUT, ?> translateToDataFlow(Operator<IN> input) {

		String name = getName() != null ? getName() : "GroupReduce at " + defaultName;

		// wrap CombineFunction in GroupCombineFunction if combinable
		if (combinable && function instanceof CombineFunction<?, ?>) {
			this.function = function instanceof RichGroupReduceFunction<?, ?> ?
				new RichCombineToGroupCombineWrapper((RichGroupReduceFunction<?, ?>) function) :
				new CombineToGroupCombineWrapper((CombineFunction<?, ?>) function);
		}

		// distinguish between grouped reduce and non-grouped reduce
		if (grouper == null) {
			// non grouped reduce
			UnaryOperatorInformation<IN, OUT> operatorInfo = new UnaryOperatorInformation<>(getInputType(), getResultType());
			GroupReduceOperatorBase<IN, OUT, GroupReduceFunction<IN, OUT>> po =
					new GroupReduceOperatorBase<>(function, operatorInfo, new int[0], name);

			po.setCombinable(combinable);
			po.setInput(input);
			// the parallelism for a non grouped reduce can only be 1
			po.setParallelism(1);
			return po;
		}

		if (grouper.getKeys() instanceof SelectorFunctionKeys) {

			@SuppressWarnings("unchecked")
			SelectorFunctionKeys<IN, ?> selectorKeys = (SelectorFunctionKeys<IN, ?>) grouper.getKeys();

			if (grouper instanceof SortedGrouping) {
				SortedGrouping<IN> sortedGrouping = (SortedGrouping<IN>) grouper;
				SelectorFunctionKeys<IN, ?> sortKeys = sortedGrouping.getSortSelectionFunctionKey();
				Ordering groupOrder = sortedGrouping.getGroupOrdering();

				PlanUnwrappingSortedReduceGroupOperator<IN, OUT, ?, ?> po =
					translateSelectorFunctionSortedReducer(
						selectorKeys, sortKeys, groupOrder, function, getResultType(), name, input, isCombinable()
					);

				po.setParallelism(this.getParallelism());
				po.setCustomPartitioner(grouper.getCustomPartitioner());
				return po;
			} else {
				PlanUnwrappingReduceGroupOperator<IN, OUT, ?> po = translateSelectorFunctionReducer(
							selectorKeys, function, getResultType(), name, input, isCombinable());

				po.setParallelism(this.getParallelism());
				po.setCustomPartitioner(grouper.getCustomPartitioner());
				return po;
			}
		}
		else if (grouper.getKeys() instanceof ExpressionKeys) {

			int[] logicalKeyPositions = grouper.getKeys().computeLogicalKeyPositions();
			UnaryOperatorInformation<IN, OUT> operatorInfo = new UnaryOperatorInformation<>(getInputType(), getResultType());
			GroupReduceOperatorBase<IN, OUT, GroupReduceFunction<IN, OUT>> po =
					new GroupReduceOperatorBase<>(function, operatorInfo, logicalKeyPositions, name);

			po.setCombinable(combinable);
			po.setInput(input);
			po.setParallelism(getParallelism());
			po.setCustomPartitioner(grouper.getCustomPartitioner());

			// set group order
			if (grouper instanceof SortedGrouping) {
				SortedGrouping<IN> sortedGrouper = (SortedGrouping<IN>) grouper;

				int[] sortKeyPositions = sortedGrouper.getGroupSortKeyPositions();
				Order[] sortOrders = sortedGrouper.getGroupSortOrders();

				Ordering o = new Ordering();
				for (int i = 0; i < sortKeyPositions.length; i++) {
					o.appendOrdering(sortKeyPositions[i], null, sortOrders[i]);
				}
				po.setGroupOrder(o);
			}

			return po;
		}
		else {
			throw new UnsupportedOperationException("Unrecognized key type.");
		}
	}