”;
Loops are used in programming languages to execute a set of statements multiple times. For example, if you want to print the digit 5 for five times, then instead of writing the VISIBLE “5” statement five times, you can run a loop with single VISIBLE “5” statement for five times.
Simple loops are represented with IM IN YR <label> and IM OUTTA YR <label>. Loops defined in this way are infinite loops and they should be terminated with a GTFO break statement.
Iteration loops have the following structure−
IM IN YR <label> <any_operation> YR <any_variable> [TIL|WILE <expression>] <code block to execute inside the loop multiple times> IM OUTTA YR <label>
Please note that inside the function body, UPPIN (increment by one), NERFIN (decrement by one), or any unary function can be used.
The TIL keyword calculates the expression as a TROOF: if it evaluates as FAIL, the loop continues once more, if it evaluates as WIN, then the loop execution stops, and continues after the matching IM OUTTA YR statement.
The WILE keyword is the opposite of TIL keyword, if the expression is WIN, execution continues, otherwise the loop exits.
Example
HAI 1.2 I HAS A VAR ITZ 0 IM IN YR LOOPY UPPIN YR VAR TIL BOTH SAEM VAR AN 10 VISIBLE SUM OF VAR AN 1 IM OUTTA YR LOOPY KTHXBYE
When the above code is compiled on any LOLCODE compiler, or on our online codingground, this will produce the following output.
sh- 4.3$ lci main.lo 1 2 3 4 5 6 7 8 9 10
”;