Skip to content

Instantly share code, notes, and snippets.

@daurnimator
Created May 26, 2010 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daurnimator/414507 to your computer and use it in GitHub Desktop.
Save daurnimator/414507 to your computer and use it in GitHub Desktop.
-- 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
> -- 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