Thread overview
Naming suggestion for this particular delegate/function
Jul 31, 2010
Bruno Medeiros
Jul 31, 2010
Dmitry Olshansky
Aug 01, 2010
Philippe Sigaud
Aug 03, 2010
Bruno Medeiros
Aug 01, 2010
Kagamin
July 31, 2010
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
July 31, 2010
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?
Generally ? transform, mutate. But most of the time you better get some natural name close to semantics of operation (in any special cases).
> Is there any usual name/term for this, I wonder, or not really?
>
Well usually it's called map. And, in fact, there is very generic (and 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

August 01, 2010
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?
>
>
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)))
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


August 01, 2010
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
August 03, 2010
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