Re: indomain/2 gives type error in version 5.5 (not before!)

From: Warwick Harvey <>
Date: Fri 29 Nov 2002 02:21:50 PM GMT
Message-ID: <>
Hi Sebastian,

On Thu, Nov 28, 2002 at 11:46:32PM -0500, Sebastian Sardina wrote:
> I have fd and fd_search loaded:
> [eclipse 35]: X :: [red, blue, green], indomain(X, random).
> type error in indomain(_248{[blue, green, red]}, random)
> Abort

Yes, this used to work.

> [eclipse 36]: X :: [red, blue, green], indomain(X, split).
> type error in indomain(_248{[blue, green, red]}, split)

This never worked.

The fd_search library was never intended to work for symbolic domains; the
fact that it did work for the random method was purely accidental (the
original author of the library was very surprised to hear that it did).

Since the last release, the fd_search code has become common between it and
the ic_search library.  In making it generic, some of the error checking and
reporting was cleaned up.  Some months later we realised that this may have
inadvertently stopped fd_search from working with symbolic domains, but when
investigating the impact of this we discovered that only the random method
had worked previously and that that had been accidental.  In the lead up to
the 5.5 release we considered trying to restore the functionality to
maintain complete compatibility, but it wasn't a high priority and it wasn't
clear how useful the functionality was anyway.  (And if we were going to
address symbolic domains, it probably should have been done properly, which
we certainly didn't have time for.)

In any event, it shouldn't be too hard to write your own indomain predicate
to do what you want.  In particular, you can use ::/2 to retrieve a
representation of the current domain of a variable, which you can then pass
to the nth_value/3 predicate provided by fd_search, which returns the Nth
value in the given domain (though if your domains are symbolic, ::/2 will
always return a simple list, which you can do with as you like).  Plug in a
random number (or whatever ordering you like) and "Bob's your uncle" as they

Once you have this predicate you can of course use it as the choice method
in a call to search/6; indeed, by providing your own selection and choice
methods, the variables don't even need to be FD variables: in the past I've
used fd_search's search/6 to solve problems involving sets.

Received on Fri Nov 29 14:22:48 2002

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