示例#1
0
文件: __init__.py 项目: dhobbs/cljppy
def merge(*maps):
    """
    Returns a dict that consists of the rest of the dict conj-ed onto
    the first. If a key occurs in more than one dict, the mapping from
    the latter (left-to-right) will be the mapping in the result.
    """
    return reduce(partial(pairwise_merge, lambda x, y: y), maps, {})
示例#2
0
文件: __init__.py 项目: dhobbs/cljppy
def merge_with(f, *maps):
    """
    Returns a dict that consists of the rest of the maps conj-ed onto
    the first. If a key occurs in more than one dict, the mapping(s)
    from the latter (left-to-right) will be combined with the mapping in
    the result by calling (f val-in-result val-in-latter).
    """
    return reduce(partial(pairwise_merge, f), maps, {})
示例#3
0
文件: Delay.py 项目: dhobbs/cljppy
 def __init__(self, f, *args):
     self.__computation = partial(f, *args)
     self.realised = False
示例#4
0
文件: test_map.py 项目: dhobbs/cljppy
def test_map_vals():
    assert map_vals({}, partial(plus, 1)) == {}
    assert map_vals({"a": 1}, partial(plus, 1)) == {"a": 2}