<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, May 9, 2015 at 1:16 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Sat, May 09, 2015 at 11:38:38AM -0400, Ron Adam wrote:<br>
<br>
> How about an operator for partial?<br>
><br>
>           root @ mean @ map $ square(xs)<br></span></blockquote><div><br></div><div>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.</div><div><br></div><div>E.g. in a white paper I just did for O'Reilly on _Functional Programming in Python_ I propose this little example implementation:</div><div><br></div><div><div>def compose(*funcs):<br></div><div>    "Return a new function s.t. compose(f,g,...)(x) == f(g(...(x)))"</div><div>    def inner(data, funcs=funcs):</div><div>        result = data</div><div>        for f in reversed(funcs):</div><div>            result = f(result)</div><div>        return result</div><div>    return inner</div></div><div><br></div><div>Which we might use as:</div><div><br></div><div>  RMS = compose(root, mean, square)</div><div>  result = RMS(my_array)</div></div><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div>