www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Naming suggestion for this particular delegate/function

reply Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Consider the familiar functional idiom "map" 
(http://en.wikipedia.org/wiki/Map_%28higher-order_function%29)

What would you call such a function parameter (either for map or just 
generally). That is, what would you call a function that takes one 
parameter of some type, and produces another object/data from that input?
Is there any usual name/term for this, I wonder, or not really?

-- 
Bruno Medeiros - Software Engineer
Jul 31 2010
next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 31.07.2010 22:07, Bruno Medeiros wrote:
 Consider the familiar functional idiom "map" 
 (http://en.wikipedia.org/wiki/Map_%28higher-order_function%29)

 What would you call such a function parameter (either for map or just 
 generally). That is, what would you call a function that takes one 
 parameter of some type, and produces another object/data from that input?

natural name close to semantics of operation (in any special cases).
 Is there any usual name/term for this, I wonder, or not really?

cute) one in Phobos by the very same name. Sadly it's somewhat bogus right now (which is known compiler fault). There are some workarounds posted on NG. -- Dmitry Olshansky
Jul 31 2010
prev sibling next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
--0016e6dab373830d3f048cbef315
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Jul 31, 2010 at 20:07, Bruno Medeiros
<brunodomedeiros+spam com.gmail> wrote:

 Consider the familiar functional idiom "map" (
 http://en.wikipedia.org/wiki/Map_%28higher-order_function%29)

 What would you call such a function parameter (either for map or just
 generally).

What parameter?
 That is, what would you call a function that takes one parameter of some
 type, and produces another object/data from that input?

Do you mean the partial application of map, is in D with map!"a*a" ? (without any argument). Is there any usual name/term for this, I wonder, or not really?

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))) For map, filter or reduce, the function is just a parameter among two. Most of the time, what they create is not a function. 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). 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. 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: 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. 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. We could have a map(fun, range) in D, I guess. Gone the currying, but welcome runtime functions. Philippe --0016e6dab373830d3f048cbef315 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <br><div class=3D"gmail_quote">On Sat, Jul 31, 2010 at 20:07, Bruno Medeiro= s <span dir=3D"ltr">&lt;brunodomedeiros+spam com.gmail&gt;</span> wrote:<br=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=

Consider the familiar functional idiom &quot;map&quot; (<a href=3D"http://e= n.wikipedia.org/wiki/Map_%28higher-order_function%29" target=3D"_blank">htt= p://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 gener= ally). </blockquote><div><br></div><div>What parameter?</div><div><br></div=
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=

That is, what would you call a function that takes one parameter of some ty= pe, 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= !&quot;a*a&quot; ? =A0 (without any argument).</div> <div><br></div><div><br></div><blockquote class=3D"gmail_quote" style=3D"ma= rgin: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 cl= ass=3D"Apple-style-span" color=3D"#888888"><br></font></blockquote><div><br=
</div><div>Not sure if I&#39;m saying something obvious to you, but map is=

them as parameter(s) or as results. So are filter, fold/reduce, unfold, sca= n, compose, power (of a function: power(f, n) =3D f(f(f(... n times)))</div=

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 ap= plication of a function: n-args functions are in fact n 1-arg functions eac= h 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, wai= ting for an iterable and returning its transformation through x*x. In not-c= urried 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 i= n Phobos (for the next release) by Andrei will allow us to do:</div><div> <br></div><div>alias map!&quot;a*a&quot; squarer; // squarer is a _generic_= function taking any range, as long as the operation a*a makes sense for th= e 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&#39;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> --0016e6dab373830d3f048cbef315--
Aug 01 2010
parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Partial-application/currying is another issue (related or not), but I 
made no mention of it.
I meant map simply as "higher-order function that applies a given 
function element-wise to a list of elements and returns a list of 
results". No currying involved.

On 01/08/2010 09:34, Philippe Sigaud wrote:
 On Sat, Jul 31, 2010 at 20:07, Bruno Medeiros
 <brunodomedeiros+spam com.gmail> wrote:

     Consider the familiar functional idiom "map"
     (http://en.wikipedia.org/wiki/Map_%28higher-order_function%29)

     What would you call such a function parameter (either for map or
     just generally).


 What parameter?

According to what I said above, the parameter that is a function (the function that will transform the elements). The only other parameter is the collection or iterator.
     That is, what would you call a function that takes one parameter of
     some type, and produces another object/data from that input?

I meant generally. So for example if you were coding in Java or some other language that does not have first order functions, but instead have to wrap them as an interface, what would you call the interface? -- Bruno Medeiros - Software Engineer
Aug 03 2010
prev sibling parent Kagamin <spam here.lot> writes:
Bruno Medeiros Wrote:

 What would you call such a function parameter (either for map or just 
 generally). That is, what would you call a function that takes one 
 parameter of some type, and produces another object/data from that input?

transform
Aug 01 2010