New Lua Examples - for last weeks delegates
Archive - Originally posted on "The Horse's Mouth" - 2009-08-01 12:23:47 - Graham Ellis
This was a bigger group than usual, and I was training them further from base than usual, and through a translation service into Spanish. So it's much more practical for individuals with questions to chat with their colleagues, before getting back in touch through our post course support form straight away. But such further follow up is welcomed.
Here are the examples:
Closure demonstration - see also blog entry
User defined sorting ("postman sort")
Reading lines from a file, various ways
When is the for loop terminations calculated?
Functional / Structured coding - an example
Basics of creating and naming variables
Extracting and counting email addresses from a server log
Block structure in Lua
Looking through all the files in a directory in Lua
Finding what your operating system is
Passing parameters to coroutines - see also blog entry
Lua's string formatting
Pattern matching - anchoring and delimiting
Single, double and square bracket strings
read from keyboard - calculate - write to screen Lua example
What can go in a variable, what are the standard libraries, what are the standard functions in the main namespace? - I have added major comments to this one!
Since the course, I have also added a promised example showing an example of graphics in Lua, and I have written up an extra note on interfacing C and C++ to Lua
The final five files are all parts of the answer to the town simulation exercise (see here for a more complete description):
An answer to the town simulation exercise
Town Specification data
Main Simulation Program
Data (object) type definition
Sample output