Up Next

6.1  Domains and Domain Variables

This library uses the domain feature provided by the ECLiPSe kernel. This means that domains need to be declared. The declaration specifies the domain values and their order. For example:

?- local domain(weekday(mo,tu,we,th,fr,sa,su)).

declares a domain with name ’weekday’ and values ’mo’, ’tu’ etc. The domain values are implicitly ordered, with ’mo’ corresponding to 1, until ’su’ corresponding to 7. Domain values must be unique within one ECLiPSe module, i.e. a symbolic value can belong to at most one domain.

A variable of a declared domain can then be created using

?- X &:: weekday.
X = X{[mo, tu, we, th, fr, sa, su]}
Yes (0.00s cpu)

or multiple variables using

?- [X,Y,Z] &:: weekday.
X = X{[mo, tu, we, th, fr, sa, su]}
Y = Y{[mo, tu, we, th, fr, sa, su]}
Z = Z{[mo, tu, we, th, fr, sa, su]}
Yes (0.00s cpu)

Up Next