On May 9, 2015, at 2:30 PM, David Mertz firstname.lastname@example.org wrote:
On Sat, May 9, 2015 at 1:16 PM, Steven D'Aprano <email@example.com mailto: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 = data for f in reversed(funcs): result = f(result) return result return inner
Which we might use as:
RMS = compose(root, mean, square) result = RMS(my_array)
Donald Stufft PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA