<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 28, 2011, at 12:38 AM, Daniel Stutzbach wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Sun, Mar 27, 2011 at 10:53 PM, Nick Coghlan <span dir="ltr">&lt;<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, Mar 28, 2011 at 2:11 PM, Daniel Stutzbach &lt;<a href="mailto:stutzbach@google.com">stutzbach@google.com</a>&gt; wrote:<br>
&gt; Is there a good use-case for the func argument?</div></blockquote><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The examples that Raymond gives in the docs (cumulative<br>
multiplication, running min/max, cash flow accumulation) look fairly<br>
solid to me.</blockquote><div><br></div><div>(I had the nagging suspicion that I was making a blunder in my email, but I couldn't see it despite rereading my email several times before sending. &nbsp;My blunder was in not rereading the patch to see the examples. &nbsp;Anyway...)</div>
<div><br></div><div>When would a running product, min, or max be useful?</div></div></blockquote><br></div><div>There's no need to speculate. &nbsp;This API has long been present in other languages and libraries.</div><div><br></div><div>Do a google code search for R's builtin functions cumsum, cumprod, cummin, and cummax.&nbsp;Look at mumpy's accumulate ufunc which works with many operators.&nbsp;APL and K also have an accumulate tool which takes arbitrary functions.</div><div><br></div><div>Or consider as an API principle that there should be s useful default (addition in this case) and also hooks or parameters provided so that users don't have to do backflips to override hard-wired behaviors.</div><div><br></div><div><br></div><div>Raymond &nbsp;</div><br></body></html>