Recherche Google
OpenMusic 6 – User ManualAdvanced Visual Programming > Iterations: OMLOOP > Iterators > Whileloop
previous pagenext page

Whileloop : Defining Iteration Conditions

General Properties

Whileloop allows a loop to go on while a condition is fulfilled .

It has only one default input : "expression", which defines a condition. This condition is expressed by a predicate1 that is connected to the input of whileloop.

Example : Using Whileloop with a Predicate

We have added a list that contains numbers and letters. We want to stop the enumeration of the list if we get something else than a number.

  1. The list is enumerated by listloop. Each item returned by listloop is sent to the predicate numberp.

  2. Numberp tests if the item is a number, and returns "t" or "nil" .

  3. 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".

  4. At each step of the loop, the results returned by listloop and numberp are gathered in a list, and EachTime prints the list.

  1. 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.

previous pagenext page
About...(c) Ircam - Centre PompidouMade with Scenari