[eclipse-clp-users] rewritten the default indomain(X, max).?

From: mauricio montecinos <mauricio.montecinos_at_gmail.com>
Date: Tue, 31 Aug 2010 14:31:11 -0400
Dears.



Two default value selection heuristics are:

1. indomain(X)

Example:

% ?- X :: [8, 7, 5, 6], indomain(X).

% X = 5





2. indomain(X, max)

Example:

% ?- X :: [8, 7, 5, 6], indomain(X, max).

% X = 8







indomain() can be rewritten as:



choose_val_indomain(Var,Val):-

            get_domain_as_list(Var,Domain),

            mem(Val,Domain).



mem(X,[X|_]).

mem(X,[_|Xs]):- mem(X,Xs).







I have rewritten indomain(X, max) as:



choose_val_indomainmax(Var,Val):-

            get_domain_as_list(Var,Domain),

            mem2(Val,Domain).



mem2(X,[]):-!,fail.

mem2(X,Lista):- maxlist(Lista,X).

mem2(X,Lista):- maxlist(Lista,Y), elimina_elemento(Y,Lista,RLista),
mem2(X,RLista).



elimina_elemento(_,[],[]):-fail.

elimina_elemento(X,[X|T],T).

elimina_elemento(X,[H|T],[H|T1]):-elimina_elemento(X,T,T1).



My question is if choose_val_indomainmax (Var, Val) is equivalent to the
default indomain(X, max).



Thanks in advance.

Sincerely.
Received on Tue Aug 31 2010 - 18:36:54 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET