Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,30 @@
|
|||
function map(f, ...)
|
||||
local t = {}
|
||||
for k, v in ipairs(...) do
|
||||
t[#t+1] = f(v)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
function timestwo(n)
|
||||
return n * 2
|
||||
end
|
||||
|
||||
function squared(n)
|
||||
return n ^ 2
|
||||
end
|
||||
|
||||
function partial(f, ...)
|
||||
local args = ...
|
||||
return function(...)
|
||||
return f(args, ...)
|
||||
end
|
||||
end
|
||||
|
||||
timestwo_s = partial(map, timestwo)
|
||||
squared_s = partial(map, squared)
|
||||
|
||||
print(table.concat(timestwo_s{0, 1, 2, 3}, ', '))
|
||||
print(table.concat(squared_s{0, 1, 2, 3}, ', '))
|
||||
print(table.concat(timestwo_s{2, 4, 6, 8}, ', '))
|
||||
print(table.concat(squared_s{2, 4, 6, 8}, ', '))
|
||||
Loading…
Add table
Add a link
Reference in a new issue