def map_with_dict(d, val): repl_f = curry(get_if)(d=d) typ = type(val) if typ == str: return repl_f(val) if typ == list or typ == set: return typ(map(repl_f, val)) if typ == dict: return keymap(repl_f, val)
def test_keymap(self): D, kw = self.D, self.kw assert keymap(inc, D({1: 1, 2: 2}), **kw) == D({2: 1, 3: 2})
def test_environ(): # See: https://github.com/pycytoolz/cycytoolz/issues/127 assert keymap(identity, os.environ) == os.environ assert valmap(identity, os.environ) == os.environ assert itemmap(identity, os.environ) == os.environ
def test_keymap(): assert keymap(inc, {1: 1, 2: 2}) == {2: 1, 3: 2}