RosettaCodeData/Task/Function-composition/00DESCRIPTION

16 lines
1 KiB
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
;Task:
Create a function, <span style="font-family:serif">compose</span>, &nbsp; whose two arguments &nbsp; <span style="font-family:serif">''f''</span> &nbsp; and &nbsp; <span style="font-family:serif">''g''</span>, &nbsp; are both functions with one argument.
The result of <span style="font-family:serif">compose</span> is to be a function of one argument, (lets call the argument &nbsp; <span style="font-family:serif">''x''</span>), &nbsp; which works like applying function &nbsp; <span style="font-family:serif"> ''f'' </span> &nbsp; to the result of applying function &nbsp; <span style="font-family:serif"> ''g'' </span> &nbsp; to &nbsp; <span style="font-family:serif"> ''x''</span>.
;Example:
<span style="font-family:serif">compose(''f'', ''g'') (''x'') = ''f''(''g''(''x''))</span>
2013-04-10 21:29:02 -07:00
Reference: [[wp:Function composition (computer science)|Function composition]]
Hint: In some languages, implementing <span style="font-family:serif">compose</span> correctly requires creating a [[wp:Closure (computer science)|closure]].
2016-12-05 22:15:40 +01:00
<br><br>