Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Our telephone lines have been repaired - sorry if you couldn't get through
+44 (0) 1225 708225 / 01225 708225
Formally open 9 a.m. to 5 p.m. (but usually around much longer

Python, Lua, Tcl, C and C++ training - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, Ruby, MySQL and Linux / Tomcat systems

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Lua module U105
Tables and the table library.
Exercises, examples and other material relating to training module U105. This topic is presented on public courses Learning to program in Lua, Lua Programming, Lua Programming

Articles and tips on this subjectupdated
4571Lua - using modules to add your own utilities
Lua is a small language ... but that doesn't mean it lacks capabiities - it just means that you need to write some code yourself to implement simple utilities that you would cherry pick from huge libraries in other languages. For example from this week's course, I've written functions to split a line ...
4273Dot or Colon separator between table name and member in Lua - what is the difference?
When do I use a dot and when do I use a colon in referencing a table member in Lua? It's a good question and one that we answer (and demonstrate to help make clear) on our Lua Programming Course. Dot refers to a table member. So if I write   source.read() I am saying "run the read function ...
4248Metatables, Metamethods, classes and objects in Lua
In Lua, almost everything (!) is held as a table. You don't have lists, hashes, dicts, arrays, objects, namespaces - you have tables. It helps consistency, in helps keep the language small - but at times it does mean you have to be a little bit more aware of how the features of tables can be combined ...
3725Lua Tables
Lua's Tables are its "collection" variables - in other words, they hold a whole series of other variables, which can be looked up by a key of some sort. I can set up a table like this:   occupancy = {2,5,5,3,2} which will set up a Lua variable called "occupancy" with five members, numbered ...
3694Special __ methods you can use in Lua metatables
In Lua, you can associate an additional table (known as a metatable) with each table of data and code you have. By doing so, repeated values and functions that apply across as whole series ("type", "class") of tables only have to be defined once. A very neat way for Lua to provide the OO facilities ...
2703Lua Metatables
In a recent article ([here]), I asked if Lua was an object oriented language - and I concluded that it supports the OO paradigm very well, even though it doesn't have keywords like "class", "private" or "extends". At the end of that article, I mentioned metatables - a subject I have carefully sidestepped ...
2699Lua tables - they are everything
In PHP, it sometimes feels like the answer to every question is "there's a function to do that" and in Lua, it seems the answer is always "it's a table" or "use a table"! I'm running a Lua course this week, and I have just posted up an example in which I set up a table and showed some of the flexibilities ...
2499ourdog is Greyhound, Staffie and Ginger Cake
It was the fact that the cake wrapper was on the bed, and not on the bedside table that was the clue that triggered me to realizing that something wasn't quite where I had left it. And examining the wrapper and finding it empty and clear, I realised that something else - the remaining slice of cake ...
2346The indexed and hashed parts of a Lua table
A Lua table contains both a sequentially indexed section and a hash keyed section (and a few other things too). When you sort the table, you sort only the index keyed section, when you use ipairs you use just the first (indexed) section, but when you use pairs you use the whole table. See source code ...
1742Lua - Table elements v table as a whole
Lua ... If you refer to a table name WITHOUT square brackets, you are referring to (and will effect) the whole table ... but if you refer to a table name and put something thereafter in square brackets, you are referring to just one element of the table. Actually, an almost identical story applies to ...
1697Sorting in lua - specifying your own sort routine
In Lua, the table.sort function allows you to sort a table and by default is sorts into the order that's given back by the < operator on each of the objects to be sorted. If you want to override this behaviour, you can pass the name of a function into Lua's sort and it will call this function each ...
Examples from our training material
asort   Sorting an Associative table
cleversort   Sorting with a user defined routine
clo_demo   User defined sorting in Lua
clone   Duplicate (clone) a table
duh   What is in a table?
imex   implode in Lua
moretab   Getting the minimum number from a table
ooco   Assignment of a table - by reference
party   Read and store data until we get a blank line
ph   pairs, ipairs and #tablename iteration
settab   Set up a table, output in reverse
sf3   Read file, split line, tables of tables
sorting   Sorting tables
spjo   Split and Join a string into / from a table
synsug   . v ["...."] v insert
t1   mixing associative and normal in table
taba   Tables as associative arrays
tabo   Tables - some basics
tat   whole table v single member, pairs v ipairs
tinies   Reading a file and creating a table
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Tables as arrays.
Table equality and copying.
Sort, Concatanate, remove and others.
Table Traversal Functions.
Building other structures from tables.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/U105.html • PAGE BUILT: Mon Feb 8 18:55:24 2016 • BUILD SYSTEM: WomanWithCat