On May 9, 2015, at 2:30 PM, David Mertz <email@example.com> wrote:On Sat, May 9, 2015 at 1:16 PM, Steven D'Aprano <firstname.lastname@example.org> wrote:On Sat, May 09, 2015 at 11:38:38AM -0400, Ron Adam wrote:
> How about an operator for partial?
> root @ mean @ map $ square(xs)I have trouble seeing the advantage of a special function composition operator when it is easy to write a general 'compose()' function that can produce such things easily enough.E.g. in a white paper I just did for O'Reilly on _Functional Programming in Python_ I propose this little example implementation:def compose(*funcs):"Return a new function s.t. compose(f,g,...)(x) == f(g(...(x)))"def inner(data, funcs=funcs):result = datafor f in reversed(funcs):result = f(result)return resultreturn innerWhich we might use as:RMS = compose(root, mean, square)result = RMS(my_array)