Clojure – Loops
”;
So far we have seen statements which are executed one after the other in a sequential manner. Additionally, statements are provided in Clojure to alter the flow of control in a program’s logic. They are then classified into flow of control statements which we will see in detail.
Sr.No. | Loops & Description |
---|---|
1 | While Statement
The ”while” statement is executed by first evaluating the condition expression (a Boolean value), and if the result is true, then the statements in the while loop are executed. |
2 | Doseq Statement
The ‘doseq’ statement is similar to the ‘for each’ statement which is found in many other programming languages. The doseq statement is basically used to iterate over a sequence. |
3 | Dotimes Statement
The ‘dotimes’ statement is used to execute a statement ‘x’ number of times. |
4 | Loop Statement
The loop special form is not like a ‘for’ loop. The usage of loop is the same as the let binding. However, loop sets a recursion point |
”;