2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,4 +1,4 @@
[[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
function that needs only the application of the remaining arguments to
produce the equivalent of applying all arguments to the original function.
@ -9,8 +9,10 @@ E.g:
: 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)
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
* Create a function fs( f, s ) that takes a function, f( n ), of one value and a sequence of values s.<br> Function fs should return an ordered sequence of the result of applying function f to every value of s in turn.
@ -22,6 +24,8 @@ Note that in the partial application of a parameter, (in the above case param1),
* 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
* 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.
<br><br>

View file

@ -14,10 +14,9 @@ function squared(n)
return n ^ 2
end
function partial(f, ...)
local args = ...
function partial(f, arg)
return function(...)
return f(args, ...)
return f(arg, ...)
end
end