<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 9, 2015, at 2:30 PM, David Mertz <<a href="mailto:mertz@gnosis.cx" class="">mertz@gnosis.cx</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, May 9, 2015 at 1:16 PM, Steven D'Aprano <span dir="ltr" class=""><<a href="mailto:steve@pearwood.info" target="_blank" class="">steve@pearwood.info</a>></span> wrote:<br class=""><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 class="">
<br class="">
> How about an operator for partial?<br class="">
><br class="">
> root @ mean @ map $ square(xs)<br class=""></span></blockquote><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><div class="">def compose(*funcs):<br class=""></div><div class=""> "Return a new function s.t. compose(f,g,...)(x) == f(g(...(x)))"</div><div class=""> def inner(data, funcs=funcs):</div><div class=""> result = data</div><div class=""> for f in reversed(funcs):</div><div class=""> result = f(result)</div><div class=""> return result</div><div class=""> return inner</div></div><div class=""><br class=""></div><div class="">Which we might use as:</div><div class=""><br class=""></div><div class=""> RMS = compose(root, mean, square)</div><div class=""> result = RMS(my_array)</div></div></div></div></div></blockquote><br class=""></div><div><br class=""></div><div>Maybe functools.compose?</div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">---</div><div class="">Donald Stufft</div><div class="">PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA</div></div></div>
</div>
<br class=""></body></html>