# Re: Lists

From: Warwick Harvey <wh_at_icparc.ic.ac.uk>
Date: Fri 02 Mar 2001 12:20:35 PM GMT
Message-ID: <3A9F9013.B4AED35C@icparc.ic.ac.uk>
```Thom Fruehwirth wrote:
> Of ocurse you can use any elements in a list (also lists again) in
> Eclipse as in any other Prolog and do whatever you like with them
> (especially recursion). The lists that occur in the lib(fd) library are
> the datastructure to hold the integers that are possible values for a
> variable. Of course, if you put a list instaed of an integer, you will
> get an error.

Actually, this is not correct.  ECLiPSe supports arbitrary ground terms
as elements of an fd domain.  To use Farouk's example list:

[eclipse 2]: X :: [[a, b], [c,d,e], f].

X = X{[f, [a, b], [c, d, e]]}
yes.

This means that the variable X has as potential values the three
elements `f', `[a, b]', and `[c, d, e]'.  (Of course, this is different
from `X :: [a, b, c, d, e, f]', where the domain elements are the six
individual atoms `a', `b', etc.)

Even this is legal:

[eclipse 12]: X :: [1, 1.0, 1_1, '1', [1]].

X = X{[1.0, 1, 1_1, '1', [1]]}
yes.

... but not particularly recommended.  :)

Note that if the domain contains elements which are not integers, then
you should stick to `#=' and `#\=' constraints, and not use `#>=', `#>',
etc. (even if the elements are "numbers", the comparisons won't work the
way you want them to).

Anyway, Farouk, what was it you were trying to do which led you to
believe that nesting lists was not possible?

Cheers,
Warwick
```
Received on Fri Mar 02 12:20:55 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:07 PM GMT GMT