Talk:Function composition: Difference between revisions

From Rosetta Code
Content added Content deleted
(Need compose intermediary.)
(ok, no C no fortran no awk no ...)
Line 1: Line 1:
Is this task subject to the "limitation" of [[First-class functions]], ruling out C (or Fortran, or...), or we can accomplish the task implementing just a function that returns f(g(x)), having as argument f, g and x? --[[User:ShinTakezou|ShinTakezou]] 15:17, 3 March 2009 (UTC)
Is this task subject to the "limitation" of [[First-class functions]], ruling out C (or Fortran, or...), or we can accomplish the task implementing just a function that returns f(g(x)), having as argument f, g and x? --[[User:ShinTakezou|ShinTakezou]] 15:17, 3 March 2009 (UTC)
:Hi, the limit is you have to create a function of f and g that returns another function. It is that other function, when applied to x would be the same as doing f(g(x)). If you look at the Python example, function compose returns function sin_cos. it is then sin_cos(x) that is equivalent to sin(cos(x)). In short, you need to create function compose. Thanks. --[[User:Paddy3118|Paddy3118]] 02:54, 4 March 2009 (UTC)
:Hi, the limit is you have to create a function of f and g that returns another function. It is that other function, when applied to x would be the same as doing f(g(x)). If you look at the Python example, function compose returns function sin_cos. it is then sin_cos(x) that is equivalent to sin(cos(x)). In short, you need to create function compose. Thanks. --[[User:Paddy3118|Paddy3118]] 02:54, 4 March 2009 (UTC)
::I.e. this is possible only for languages that have [[First-class functions]] (by the way, it seems like this task is already covered by showing that the language has first class functions in [[First-class functions]] task page) --[[User:ShinTakezou|ShinTakezou]] 11:27, 4 March 2009 (UTC)

Revision as of 11:27, 4 March 2009

Is this task subject to the "limitation" of First-class functions, ruling out C (or Fortran, or...), or we can accomplish the task implementing just a function that returns f(g(x)), having as argument f, g and x? --ShinTakezou 15:17, 3 March 2009 (UTC)

Hi, the limit is you have to create a function of f and g that returns another function. It is that other function, when applied to x would be the same as doing f(g(x)). If you look at the Python example, function compose returns function sin_cos. it is then sin_cos(x) that is equivalent to sin(cos(x)). In short, you need to create function compose. Thanks. --Paddy3118 02:54, 4 March 2009 (UTC)
I.e. this is possible only for languages that have First-class functions (by the way, it seems like this task is already covered by showing that the language has first class functions in First-class functions task page) --ShinTakezou 11:27, 4 March 2009 (UTC)