I cannot get a simple while loop to work in lisp!
(loop (while (row >= 0))
setf(row (- row 1))
(collect (findIndex row col))
while row is more or equal to 0 i want to decrement row and collect the result given by findIndex method. Suppose the col is given.
Thanks!!!
Syntax. do { statement(s); } while( condition ); Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop executes once before the condition is tested. If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop executes again.
The loop construct is the simplest form of iteration provided by LISP. In its simplest form, it allows you to execute some statement(s) repeatedly until it finds a return statement. The loop for construct allows you to implement a for-loop like iteration as most common in other languages.
A do while loop is a control flow statement that executes a block of code at least once, and then repeatedly executes the block, or not, depending on a given boolean condition at the end of the block. Some languages may use a different naming convention for this type of loop.
The correct form of the loop is the following:
(loop while (>= row 0)
do (setf row (- row 1)) ; or better: do (decf row)
collect (findIndex row col))
For a detailed description of the loop syntax, see the manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With