Used to look up which domain a particular value belongs to, and which numerical index it has within this domain. Only domain definitions which are visible in the caller module are taken into account.
Domain is returned as a pair DefinitionModule:DomainName which unabiguously identifies the domain definition that contains the value. Index is unified with a natural number corresponding to the position of Value within that domain definition (starting from 1).
:- local domain(colour(red,green,blue)). :- export domain(vowel(a,e,i,o,u)). :- local domain(abc(a,b,c)). Domain value a not unique in module eclipse out of range in local domain(abc(a, b, c)) Abort ?- domain_index(green, Domain, Index). Domain = eclipse : colour Index = 2 Yes (0.00s cpu) ?- domain_index(a, Domain, Index). Domain = eclipse : vowel Index = 1 Yes (0.00s cpu) ?- domain_index(b, Domain, Index). No (0.00s cpu) ?- domain_index(yellow, Domain, Index). No (0.00s cpu)