Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

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 U103
Conditionals and loops
Exercises, examples and other material relating to training module U103. This topic is presented on public courses Learning to program in Lua, Lua Programming, Lua Programming

Articles and tips on this subjectupdated
4574repeat until in Lua - a one or more rather than a zero or more loop
The "repeat until" structure in Lua provides a loop with condition checking at the end - in other words, it's a "one or more times" loop, unlike while which is a "zero or more times" loop. Syntax - straightforward; example:   repeat     io.write("How many people? ")     said ...
4323Learning to program - Loop statements such as while
If your program always ran each statement just once (indeed skipping over statements which were in blocks in false conditions) it would run very quickly and would have little use. You couldn't (for example) run a program which went through a whole series of results from a database query and displayed ...
4322Learning to Program - the conditional statement (if)
Every language has some sort of conditional statement. That's a way of looking at some sort of setting or status in the program and performing some sort of action based on that setting or status. such statements take the form ...   if {some sort of condition is true} then {run a group of ...
4272Lazy operators in Lua - what they mean, and examples
If you use the word or in an expression in Lua, the expression to the right of the word will only be evaluated and returned of the value to the left is nil. So a very common idiom is:   stuff = stuff or {} which means "if stuff already has a value, leave it alone - otherwise make it an empty ...
3397Does a for loop evaluate its end condition once, or on every iteration?
All the languages that we teach have a for loop or the equivalent, which is a clean way of repeating a block of code with a rising or falling index number. It's used in many circumstances - for example in iterating through the months of the year (for m goes from 1 to 12) of in stepping through all ...
3686The goto statement in Lua
In the past there was considerable debate in academia and industry on the merits of the use of goto statements, and indeed Lua didn't have them until release 5.2. Well used in Lua, they can provide an escape from inner loops, jumping to a label using a ::label:: format. For example:   for ...
3558Python or Lua - which should I use / learn?
"Should I learn and use Python or Lua" - a question to me. The questioner was perceptive, knowing that he shouldn't try to learn lots of languages at the same time, and that he should always limit the "basket" of languages used within his applications - in fact, he was wondering if he could select just ...
2454For loops in Lua
As an old Fortran programmer, I remember that a for loop was given a start point, an end point and a step ... and they had to be whole numbers (integers). Lua's for loops can be used that way, but they can be used a lot more flexibly too. From, to, step for loops Th egood news is that Lua works in ...
2455Lua examples - coroutines, error handling, objects, etc
I have presented a bespoke Lua course over the last three days ... and it has lead me to some interesting new examples which I'm sharing here. Object Orientation is more a way of thinking and coding than a language feature in Lua - when you set up a piece of data / structure / object, you do so in a ...
2351Ternary operators alternatives - Perl and Lua lazy operators
"If the gender is male, the answer is him, but if the gender is female, the answer is her". A common situation in programming - [is/are], [him/her], [yes/no], [child/children], [ice/water/steam], [public/private] - and C and Perl and PHP provide the "ternary" operator ? and : to provide a shorthand ...
1738Clean code, jump free (Example in Lua)
The "goto" statement - in languages that still support it - is regarded with disdain by Computer Scientists as it makes for spaghetti code - hard to follow and going all over the place! In some ways, loop controls "break" and "continue" ("last", "next" and "redo" in Perl; "next", "redo", "retry" and ...
1696Saying NOT in Perl, PHP, Python, Lua ...
"Isn't there one standard way to say NOT?" asked one of my delegates on today's course - and it's an excellent question. But the answer to a question about a negative subject is itself in the negative - no, there isn't just a single way! In fact .. I can think of no fewer that 12 ways! • 1. ! ...
1685Short circuit evaluation (lazy operator) in Lua
In Lua, if a partial expression evaluates to true the following section will NOT be evaluated if it follows an or because the whole thing cannot be true. If a partial expression evaluates to false, the following section will NOT be evaluated if it follow an and because the whole thing must be true. If ...
Examples from our training material
andor   Lazy and / or operators
bpm   string.find v string.gfind
clike   for loop with pairs and ipairs
clumpit   for loop termination
doco   Changing loop counts
exa   Loops and conditionals - exchange rate example
floo   for loop in which end condition changes
kz   Example of a for loop
lif   if, elseif, else
ll2   while loop and repeat until loop
lloops   while and for loops
lsx   Lua for loop - termination
meerkat   Lazy Operators
runt   repeat until
swans.lua   Swan family - Lua
tchart   for loop with start, end and step
wcd   Comparison of while and until loops
whilly   Writing cleaner code without break or continue
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
If while repeat break do and for.
Comparing numbers comparing strings.
Equality and nil.
Combining Conditions.
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., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/U103.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb