Created
May 26, 2010 13:50
-
-
Save daurnimator/414508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generalized Partial Application Implementation In Lua | |
-- Azer Koculu <azerkoculu@gmail.com> | |
-- Mon May 24 10:33:40 UTC 2010 | |
local function partial(fn,initialargs) | |
return function(...) | |
args = {} | |
if initialargs then table.foreach(initialargs,function(ind,el) table.insert(args,el) end) end | |
for i=0,arg['n'],1 do table.insert(args,arg[i]) end | |
return fn(unpack(args)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> -- Example Usage | |
> = partial(print, { "de", "lua" })("fabula","narratur") | |
de lua fabula narratur |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment