Constructor
new ConstraintList()
Creates an array from arguments.
Also computes the first variable from the list
v0, v1, v2,...
such that neither it nor
any variable after it in that list appears in any of the constraints.
Call this vN
. See nextNewVariable
for the use.
Parameters:
Name | Type | Description |
---|---|---|
...constraints |
an arbitrary number of Constraints (can be zero) |
- Source:
Classes
Members
length
- Source:
Methods
add()
Adds constraints only if they are not in the current list (as if we had a set).
Parameters:
Name | Type | Description |
---|---|---|
...constraints |
the constraints to be added |
- Source:
Returns:
the new contents
computeBindingConstraints()
Extracts from each pattern a list of metavariable pairs (m1,m2).
Such a pair means the restriction that a solution S cannot have S(m1) appearing free in S(m2).
Pairs are represented by an object with
inner: m1
and outer: m2
properties.
- Source:
copy()
- Source:
Returns:
a deep copy of the list.
empty()
Makes the list empty by removing all constraints
- Source:
equals()
- Source:
Returns:
true only if both lists contain the same constraints.
firstPairSatisfying()
- Source:
Returns:
an array of length two containing the first two constraints satisfying the given binary predicate,
or null if there is not one.
firstSatisfying()
- Source:
Returns:
the first constraint in the list satisfying the given predicate, otherwise null.
getBestCase() → {Constraint}
Returns the constraint with the 'best' case from the start of the list.
The cases are defined in the corresponding paper.
- Source:
Returns:
the constraint with the best case
- Type
- Constraint
indexAtWhich()
- Source:
Returns:
the first index at which predicate is true when evaluated on contents, -1 otherwise.
instantiate(patterns)
Takes a ConstraintList object containing the patterns that the
substiutions in this object will be applied to. Each substitution is
applied to the pattern satisfying the conditions described in the summary
paper (section 3).
Parameters:
Name | Type | Description |
---|---|---|
patterns |
ConstraintList | a non empty constraint list |
- Source:
isFunction()
Some constraint lists are functions from the space of metavariables to the space of expressions.
To be such a function, the constraint list must contain only constraints
whose left hand sides are metavariables (called substitutions above),
and no metavariable must appear in more than one constraint.
- Source:
lookup(variable)
If the constraint list is a function, this routine returns the expression associated with a given metavariable.
Parameters:
Name | Type | Description |
---|---|---|
variable |
a string or expression |
- Source:
Returns:
the expression of the constraint with the pattern that equals
the variable, null otherwise.
nextNewVariable()
- Source:
Returns:
a new variable starting at
vN
(see constructor for definition of vN
).
remove()
Removes constraints from the list and ignores any constraints not in the list.
Parameters:
Name | Type | Description |
---|---|---|
...constraints |
the constraints to be removed |
- Source:
Returns:
the new contents