[ library(fd) | Reference Manual | Alphabetic Index ]
element(?Index, +List, ?Value)
Value is the Index'th element of the integer list List.
- ?Index
- A variable or an integer.
- +List
- A non-empty list of integers.
- ?Value
- A variable or an integer.
Description
   This constraints can be used in a variety of programs to state a
   relation between two domain variables.  List is a list of integers and
   the constraint states that its Index'th element is equal to Value, i.e.
                             List_Index = Value
   Every time Index or Value is updated, this constraint is activated and
   the domain of the other variable is updated accordingly.
Fail Conditions
   Fails if Value is not the Index'th element of List.
Resatisfiable
   No.
Examples
   [eclipse 13]: element(I, [1,3,6,3], V).
   I = I :: [1 .. 4]
   V = V :: [1, 3, 6]
   Delayed goals:
   element(I :: [1 .. 4], t(1, 3, 6, 3), V :: [1, 3, 6], 4, 3)
   yes.
   [eclipse 14]: element(I, [1,3,6,3], V), V ## 3.
   I = I :: [1, 3]
   V = V :: [1, 6]
   Delayed goals:
   element(I :: [1, 3], t(1, 3, 6, 3), V :: [1, 6], 2, 2)
   yes.
See Also
:: / 2, #:: / 2, atmost / 3