Este contenido no está disponible en el idioma seleccionado.
Chapter 16. Patterns
16.1. Patterns Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
A pattern element is the most important Conditional Element. It can potentially match on each fact that is inserted in the working memory. A pattern contains constraints and has an optional pattern binding.
16.2. Pattern Example Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
This is what a pattern looks like:
Note
An
and cannot have a leading declaration binding. This is because a declaration can only reference a single fact at a time, and when the and is satisfied it matches both facts.
16.3. Pattern Matching Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
A pattern matches against a fact of the given type. The type need not be the actual class of some fact object. Patterns may refer to superclasses or even interfaces, thereby potentially matching facts from many different classes. The constraints are defined inside parentheses.
16.4. Pattern Binding Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Patterns can be bound to a matching object. This is accomplished using a pattern binding variable such as
$p.
16.5. Pattern Binding with Variable Example Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
This is what pattern binding using a variable looks like:
Note
The prefixed dollar symbol (
$) is not mandatory.
16.6. Constraints Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
A constraint is an expression that returns
true or false. For example, you can have a constraint that states five is smaller than six.