Partial function application: Difference between revisions

Content added Content deleted
m (added whitespace before the TOC (table of contents), added other whitespace to the task's preamble.)
Line 1: Line 1:
{{task|Programming language concepts}}
{{task|Programming language concepts}}

[[wp:Partial application|Partial function application]] is the ability to take a function of many
[[wp:Partial application|Partial function application]]   is the ability to take a function of many
parameters and apply arguments to some of the parameters to create a new
parameters and apply arguments to some of the parameters to create a new
function that needs only the application of the remaining arguments to
function that needs only the application of the remaining arguments to
Line 10: Line 11:
: Then <code>partial(f, param1=v1)</code> returns <code>f'(param2)</code>
: Then <code>partial(f, param1=v1)</code> returns <code>f'(param2)</code>
: And <code>f(param1=v1, param2=v2) == f'(param2=v2)</code> (for any value v2)
: And <code>f(param1=v1, param2=v2) == f'(param2=v2)</code> (for any value v2)



Note that in the partial application of a parameter, (in the above case param1), other parameters are not explicitly mentioned. This is a recurring feature of partial function application.
Note that in the partial application of a parameter, (in the above case param1), other parameters are not explicitly mentioned. This is a recurring feature of partial function application.



;Task
;Task
Line 23: Line 26:


* Test fsf1 and fsf2 by evaluating them with s being the sequence of integers from 0 to 3 inclusive and then the sequence of even integers from 2 to 8 inclusive.
* Test fsf1 and fsf2 by evaluating them with s being the sequence of integers from 0 to 3 inclusive and then the sequence of even integers from 2 to 8 inclusive.



;Notes
;Notes
* In partially applying the functions f1 or f2 to fs, there should be no ''explicit'' mention of any other parameters to fs, although introspection of fs within the partial applicator to find its parameters ''is'' allowed.
* In partially applying the functions f1 or f2 to fs, there should be no ''explicit'' mention of any other parameters to fs, although introspection of fs within the partial applicator to find its parameters ''is'' allowed.
* This task is more about ''how'' results are generated rather than just getting results.
* This task is more about ''how'' results are generated rather than just getting results.
<br><br>


=={{header|Ada}}==
=={{header|Ada}}==