
domain_index(+Value, -Domain, -Index)

   Value is defined in Domain with positional number Index

Arguments
   Value               Atomic term
   Domain              Variable or structure of the form Module:DomainName
   Index               Variable or integer starting from 1

Type
   Comparing and Sorting

Description

	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 context 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).
	


Modes and Determinism
   domain_index(+, -, -) is semidet

Modules
   This predicate is sensitive to its module context (tool predicate, see @/2).

Fail Conditions
   The value does not occur in any of the visible domain definitions

Exceptions
     4 --- Value is not instantiated
     5 --- Value is not atomic

Examples
   
    :- 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)
    

See Also
   domain / 1, current_domain / 3
