Whileloop allows a loop to go on
as long as a condition is fulfilled
.
It has only one default input : "expression", which defines a condition. This condition can be expressed by a predicate[1] or any other value connected to the input of whileloop.
Example : Using Whileloop with a Predicate
A list that contains numbers and letters is enumerated until something else than a number is reached.
The list is enumerated by listloop. Each item returned by listloop is sent to the predicate numberp.
Numberp tests if the item is a number, and returns "t" or "nil" .
The result of the predicate is returned to whileloop. As long as whileloop gets "t", the loop goes on.
When numberp returns "nil", whileloop stops the loop, and finally returns "done".
At each step of the loop, the results returned by listloop and numberp are gathered in a list, and EachTime
prints the list.
Références :
Predicate
A predicate verifies the property of a thing or a relation between two things. It has two possible answers : "true", and "false", that is, "t", or "nil" in Lisp.