users-prolog
[Top][All Lists]

## Re: Max of list with constrained variables

 From: Daniel Diaz Subject: Re: Max of list with constrained variables Date: Tue, 28 May 2013 16:47:06 +0200 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

```Hello,

max_list only work with integers.

Here you have to use FD constraints (like #= and the functor max/2).

lmax([X|L], M) :-
lmax1(L, X, M).

lmax1([], X, X).

lmax1([Y|L], X, M) :-
M1 #= max(X, Y),
lmax1(L, M1, M).

Daniel

Le 24/05/2013 16:23, Georgios Samaras a écrit :
```
```I have a list, which, for N = 5 (for instance), it is like this:
[3*(1-_#0(0..1)),2*(1-_#18(0..1)),1*(1-_#36(0..1)),4*(1-_#54(0..1)),2*(1-_#72(0..1))].

I am working on a finite domain constraint environment and I tried this
max_list(MaxFilter, M0),

and I got this error (since the variable does not have a value at this
moment)
uncaught exception: error(type_error(evaluable,_#4195373(0..1)),(=<)/2)

In Eclipse, I would use eval and in SWI, I used this predicate
lmax([H|T], X):-
foldl(max_, T, H, Exp),
X #= Exp.
max_(E, X, max(E, X)).

but I did not find any equiivalent of foldl in GNU.

What should I do? Any ideas? I am stuck and I have been searching the
whole internet for days...

//G. Samaras

_______________________________________________
Users-prolog mailing list
https://lists.gnu.org/mailman/listinfo/users-prolog

```
```

--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.

```