<br><div class="gmail_quote">On Sat, Jul 31, 2010 at 20:07, Bruno Medeiros <span dir="ltr"><brunodomedeiros+spam@com.gmail></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Consider the familiar functional idiom "map" (<a href="http://en.wikipedia.org/wiki/Map_%28higher-order_function%29" target="_blank">http://en.wikipedia.org/wiki/Map_%28higher-order_function%29</a>)<br>
<br>
What would you call such a function parameter (either for map or just generally). </blockquote><div><br></div><div>What parameter?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
That is, what would you call a function that takes one parameter of some type, and produces another object/data from that input?<br></blockquote><div><br></div><div>Do you mean the partial application of map, is in D with map!"a*a" ? (without any argument).</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Is there any usual name/term for this, I wonder, or not really?<br><font class="Apple-style-span" color="#888888"><br></font></blockquote><div><br></div><div>Not sure if I'm saying something obvious to you, but map is a higher-order function: a function that acts on functions, either taking them as parameter(s) or as results. So are filter, fold/reduce, unfold, scan, compose, power (of a function: power(f, n) = f(f(f(... n times)))</div>
<div>For map, filter or reduce, the function is just a parameter among two. Most of the time, what they create is not a function.</div><div><br></div><div>In curried language like Haskell, you can easily create the partial application of a function: n-args functions are in fact n 1-arg functions each delivering the next step (a function).</div>
<div>So map x*x [0,1,2,3,4] is [0,1,4,9,16], but map x*x is a function, waiting for an iterable and returning its transformation through x*x. In not-curried language, map x*x is considered a partial application of map.</div>
<div><br></div><div>Note in D the asymmetry between the function which is a compile-time argument and the range, a runtime argument. A recent change in Phobos (for the next release) by Andrei will allow us to do:</div><div>
<br></div><div>alias map!"a*a" squarer; // squarer is a _generic_ function taking any range, as long as the operation a*a makes sense for the range elements.</div><div><br></div><div><br></div><div>Before, we could do this with reduce, but not map and filter. That was originally to avoid a bug in the compiler :-) but it's easy to code and very useful.</div>
<div><br></div><div>We could have a map(fun, range) in D, I guess. Gone the currying, but welcome runtime functions.</div><div><br></div><div>Philippe</div><div><br></div></div>