OpenMusic

Visual Programming | Computer-Assisted Composition

Navigation : Previous | Next

Predicates: In Practice

Predicates can be used as conditions defining the execution of an operation. Hence, predicates must be connected to

If a given property or a relation is verified by a predicate, the operation is performed.

Example : Using a Type Predicate as a Test Argument

Here, we want to delete floats from a list with list-filter. List-filter rejects or passes elements from a list, depending on the predicate taken as argument.

It has three default inputs :

  1. a predicate, whose default value is numberp

  2. a list

  3. an action - “reject” or “pass”.

—|—

The floatp predicate and the “reject” option have been assigned to list- filter, so that floats are rejected.

—|—

Using a Function on Lambda Mode

A predicate can be a function on “lambda” mode.

—|—

Using a Lambda Function as a Predicate

References :

Contents :

Navigation : Previous | Next