ForeverDev

Untitled

Nov 6th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. _ = setmetatable({}, {
  2.     __call = function() end,
  3.     __pow = function(self, def)
  4.         getfenv()[def[1]] = (
  5.             type(def[2]) == "function" and setmetatable({def[2]},{
  6.                 __index = function(self2, other2)
  7.                     self2[1](unpack(other2))
  8.                 end
  9.             }) or def[2]
  10.         )
  11.     end
  12. })
  13.  
  14. _(_ ^ {"sum", function(...)
  15.     _(_ ^ {"x", 0})
  16.     for i = 1, #({...}) do
  17.         x = x + ({...})[i]
  18.     end
  19.     print(x)
  20. end})
  21.  
  22. _(sum[{5, 10, 15}])
Advertisement
Add Comment
Please, Sign In to add comment