Recherche Google
OpenMusic 6 – User ManualAdvanced Visual Programming > Control Structures > Predicates > Equality Predicates
previous pagenext page

Equality Predicates

In Lisp, equality can be interpreted different ways. For instance, the character "a" is a concept that can be represented by several different glyphs – A, a, a – which can be considered identical or not, depending on the predicate. These predicates are not available in the menus : their name must be typed directly in a patch editor.

Functionalities

There are four equality test predicates :

  • eq
  • eql
  • equal
  • equalp.

The eq and eql predicates are the strictest, the equal and equalp are the most open predicates, and are relevant to most cases.

Returns "t" with

Examples

identical objects with the same reference

integers and ratios of same value

glyphs representing the same character

-> "nil" : strings, lists, floats, ratios that produce floats.

eq A A -> t

eq 2 2/1 -> t

eq A a -> t

eq "A" "A" -> nil

eq (A B C) (A B C) -> nil

eq 2.5 2.5 -> nil

Returns "t" with

Examples

eq or eql objects

structurally similar objects

strings with identical glyphs

floats of same value

equal (A (b) C) (a (B) c) -> t

equal "A" "A" -> t

equal "A" "a" ->nil

equal 2.5 2.5 ->t

Returns "t" with

Examples

eq, eql or equal objects

strings with similar glyphs

numbers of same numerical value

equalp "A" "a" -> t

equalp 2 2/1 -> t

equalp 2.5 2.5 -> t

equalp 2 2.0 -> t

Notes
  • For instance, two chords with the same reference are eq.
  • In some cases, equal considers the object. In other cases, equal considers the concept.
  • Equalp only considers values and concepts, not their representation.

Equality Predicates in Lisp and OM Functions

Many Lisp and OM functions need a predicate to operate.

Functions that perform operations upon lists, for instance, have a default equality predicate used for identifying similar items in two different lists, and manipulate them. Note that this predicate can be redefined to modify the behaviour of the function.

Using Lambda Functions as Predicates :
previous pagenext page
About...(c) Ircam - Centre PompidouMade with Scenari