I would like to be able to curry merge_with
:
merge_with
works as I expect
>>> from cytoolz import curry, merge_with
>>> d1 = {"a" : 1, "b" : 2}
>>> d2 = {"a" : 2, "b" : 3}
>>> merge_with(sum, d1, d2)
{'a': 3, 'b': 5}
On a simple function, curry
works as I expect:
>>> def f(a, b):
... return a * b
...
>>> curry(f)(2)(3)
6
But I'm not able to "manually" make a curried version of merge_with
:
>>> curry(merge_with)(sum)(d1, d2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'dict' object is not callable
>>> curry(merge_with)(sum)(d1)(d2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'dict' object is not callable
The pre-curried version works:
>>> from cytoolz.curried import merge_with as cmerge
>>> cmerge(sum)(d1, d2)
{'a': 3, 'b': 5}
Where is my mistake?