During some courses, I write few (if any) new examples in front of my delegates, rather relying on the standard ones in the training notes (which I wrote anyway!) and making small changes and adjustments to illustrate how things work. On other courses, though, I write a some new examples from scratch - and such was the case during last Thurday and Friday's two day
Lua training class.
Here - primarily for the delagates in that class - are links to the many of the new examples, which I have added to our on line resource. If you follow the links to any of these, you'll be offered links to other related examples too!
Lua Fundamentals
Comments in Lus
Simple sting.format example
for loop example in Lua
strip.rep to repeat a string
getting the minimum value from a table in Lua
Pattern Matching -getting names from amongst a stream of punctuation
Lua functions and modules
Variable number of arguments to a function
Lua functions to return larger of two values and largest of a table of values
How sorting works in Lua - looking under the counter
A Lua program that calls in a module and
the module itself
An function which could usefully be turned into a coroutine and
that example amended to run as a coroutine
Towards Object Orientation in Lua
A reminder of tables
Adding Lusa's metables to change functionallity
Creating and using a table of Lua 'objects'
Redefining operator behaviour on tables in Lua
Lua is a really excellent language with a small "footprint" - the more I use it, the more I like it (and I like it a lot!). You won't find the "bloat" of other open source languages, but you WILL find nifty and useful features which come together to make it a very valuable programming tool; it's this feature set that has led to its widespead adoption in the games industry where (for example) it's used in "The world or Warcraft" to customise the user interface.
(written 2008-07-06, updated 2008-08-05)
Associated topics are indexed under
U101 - Introduction to Lua. [2310] Learning to write high quality code in Lua - (2009-07-30)
[1842] Lua Course, and the Wiltshire Countryside too - (2008-10-16)
[1737] Rules, suggestions, considerations for Lua variable names - (2008-08-05)
[1695] Lua Course - here is the index - (2008-07-03)
[1111] Training in Lua - (2007-03-16)
U102 - Lua - Numbers and the Math library. [2509] A life lesson from the accuracy of numbers in Excel and Lua - (2009-11-21)
[2345] Automatically initialising Lua variables the first time - (2009-08-10)
[1744] Lua examples, Lua Courses - (2008-08-08)
U106 - Lua - Functions. [2949] Lua - variable function arguments and select - (2010-09-08)
[2723] Returning multiple values from a function - Lua - (2010-04-15)
[2455] Lua examples - coroutines, error handling, objects, etc - (2009-10-15)
[2356] Passing multiple results back from a function - Lua, Python, etc - (2009-08-13)
[2347] Dot, dot, dot in Lua - variable length parameter lists - (2009-08-11)
[2312] What are closures in Lua? - (2009-07-31)
[1847] Lua - IAQ (Infrequently Answered Questions) - (2008-10-18)
[1743] First class functions in Lua lead to powerful OO facilities - (2008-08-07)
[1697] Sorting in lua - specifying your own sort routine - (2008-07-05)
[1685] Short circuit evaluation (lazy operator) in Lua - (2008-06-22)
U107 - Object Orientation - the Lua way [3524] Metaclasses (Python) and Metatables (Lua) - (2011-11-17)
[3396] Tables as Objects in Lua - a gentle introduction to data driven programming - (2011-08-17)
[3142] Private and Public - and things between - (2011-01-22)
[2710] __index and __newindex in Lua - metatable methods - (2010-04-05)
[2703] Lua Metatables - (2010-04-02)
[2701] Is Lua an Object Oriented language? - (2010-04-01)
[2359] A fresh example - objects the Lua way - (2009-08-13)
[2318] For Lua Programmers AND for Town Planners - (2009-08-02)
[1819] Calling base class constructors - (2008-10-03)
[1692] Towards Object Oriented Programming in Lua - (2008-06-30)
U109 - Lua - Modules [2358] Encapsulating shared code in a Lua module - (2009-08-13)
U114 - Lua - Threading and Coroutines. [3395] Parallel but not really parallel. Moving game characters. Coroutines in Lua. - (2011-08-17)
[2314] Passing parameters to a coroutine in Lua - (2009-08-01)
[1870] What to do with a huge crop of apples - (2008-11-04)
[1691] Co-routines in Lua - co-operative processing - (2008-06-29)
Some other Articles
Perl ... adding to a list - end, middle, startRunning operating system commands in PerlTraining Course and Business Conference TechnologyFTP server on Fedora LinuxIf you are learning Lua, here are some more examplesDealing with The PressSaying NOT in Perl, PHP, Python, Lua ...Defensive coding techniques in PHP?