Curried versions of Python operator module.
Note: Currying is not partial function application. Which is not
the same as
functools.partial from the standard library. Currying a
function converts a tuple of arguments into a composition of functions
which take 1 argument and return another function until the function is
saturated. Partial function application allows applying an arbitrary
number of arguments to a call initially and then supply the rest in a
$ python setup.py install
>>> from curry import mul, add, xor, and_, neg, sub, flip, methodcaller >>> f = add(1) >>> f(2) 3 >>> f(3) 4 >>> neg(1) -1 >>> h = and_(True) >>> h(True) True >>> h(False) False >>> map(add(1), [2,3,4]) [3, 4, 5] >>> map(mul(3), [2,3,4]) [6, 9, 12] >>> print xor(2) <operator.xor 2> >>> flip(sub)(5, 10) 5 >>> concat = lambda xs: methodcaller('join', xs) >>> f = concat(['a','b','c']) >>> f(',') 'a,b,c' >>> f(' ') 'a b c'
Copyright (c) 2012 Stephen Diehl ( firstname.lastname@example.org ) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.