[NEXT] [PREV]    HANDBOOK / GENTLE PRIMER / A Summary of Predefined Predicates /

The Predicates eq, ne, lt, le, ge, gt

Gentle
Applications
Concepts
Examples
Handbook
Support

The conditions eq and ne are used to compare values for equality.
```
eq(X, Y)
```
succeeds if X is equal to Y and fails otherwise.
```
ne(X, Y)
```
succeeds if X is not equal to Y and fails otherwise. These predicates work for all types including user-defined types, i.e. they may be used to compare terms. For example,
```
eq(list(red, X), list(red, list(yellow,nil)))
```
succeeds if X is list(yellow,nil).

The predicates gt, ge, lt, and le are defined only for the types INT and STRING.

```
gt(X, Y)
```
succeeds if X is greater than Y and fails otherwise.

For example,

```
gt(N, 0)
```
succeeds if N is a positive number.

In the case of strings, the lexicographical order is used for comparison. For example,

```
gt("axy", "abc")
gt("aaaa", "aa")
```
succeed.

Similarly, ge, lt, and le stand for ``greater or equal'', ``less than'', and ``less or equal'', respectively