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.3.0 : Wed Sep 25 2024 - 15:13:20 CEST