def update_with(d1, d2, aggregator, zero):
    """
    Fold the right dictionary into the left.
    This is a mutating function
        :param d1: Dictionary to fold into
        :param d2: Dictionary draw updates from
        :param aggregator: Definition of how to update d1
        :param zero: What to do if a key in d2 isn't in d1
    """
    for k, v in d2.items():
        if k not in d1:
            d1[k] = zero()
        d1[k] = aggregator(d1[k], v)
    return d1
