If you're 1) new to Lua, from some C++/C# like language, 2) not mega-concerned about speed and memory allocations, and 3) Not ready to think about metatables, tail calls and other advanced features mentioned in previous answers, then IMO a variation of Soni L's first answer is the most readable for noobs: