exo updates

This commit is contained in:
Vitor Santos Costa 2013-06-05 23:00:57 +01:00
parent 889279cd81
commit 4826d92709
2 changed files with 42 additions and 27 deletions

View File

@ -170,6 +170,34 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
pt = c+(it->links[off]+1);
end = c+(it->links[off]+n);
} else {
if (!IsVarTerm(min)) {
Int x;
if (!IsIntegerTerm(min)) {
min = Yap_Eval(min);
if (!IsIntegerTerm(min)) {
Yap_Error(TYPE_ERROR_INTEGER, min, "data-base constraint");
return FAILCODE;
}
}
x = IntegerOfTerm(min);
if (x >= IntegerOfTerm(S[LOCAL_exo_arg])) {
return FAILCODE;
}
}
if (!IsVarTerm(max)) {
Int x;
if (!IsIntegerTerm(max)) {
max = Yap_Eval(max);
if (!IsIntegerTerm(max)) {
Yap_Error(TYPE_ERROR_INTEGER, max, "data-base constraint");
return FAILCODE;
}
}
x = IntegerOfTerm(max);
if (x <= IntegerOfTerm(S[LOCAL_exo_arg])) {
return FAILCODE;
}
}
return NEXTOP(NEXTOP(it->code,lp),lp);
}

View File

@ -9,7 +9,10 @@
:- module(exo_interval,
[max/2,
min/2,
max/1,
min/1,
any/2,
any/1,
max/3,
min/3,
any/3,
@ -40,6 +43,15 @@ max(X, X) :-
min(X, X) :-
insert_atts(X, i(_,_,min)).
max(X) :-
insert_atts(X, i(_,_,max)).
any(X) :-
insert_atts(X, i(_,_,any)).
min(X) :-
insert_atts(X, i(_,_,min)).
X #> Y :-
( var(X) -> insert_atts(X, i(Y,_,_))
@ -55,49 +67,24 @@ X #> Y :-
X #>= Y :-
( var(X) -> insert_atts(X, i(Y-1,_,_))
;
( var(Y) -> insert_atts(Y, i(X+1,_,_) ) ;
true
)
;
var(Y) -> insert_atts(Y, i(_,X+1,_))
;
X >= Y
).
X #< Y :-
( var(X) -> insert_atts(X, i(_,Y,_))
;
( var(Y) -> insert_atts(Y, i(X,_,_) ) ;
true
)
;
var(Y) -> insert_atts(Y, i(X,_,_))
;
X < Y
).
X #=< Y :-
( var(X) -> insert_atts(X, i(Y+1,_,_))
;
( var(Y) -> insert_atts(Y, i(X-1,_,_) ) ;
true
)
;
var(Y) -> insert_atts(Y, i(X-1,_,_))
;
X =< Y
).
X #= Y :-
( var(X) -> insert_atts(X, i(Y-1,Y+1,_))
;
( var(Y) -> insert_atts(Y, i(X-1,X+1,_) ) ;
true
)
;
var(Y) -> insert_atts(Y, i(X-1,X+Y,_))
;
( var(X) -> insert_atts(X, i(Y-1,Y+1,_)) ;
X =:= Y
).
@ -173,5 +160,5 @@ expand_op(A1, A2, A3) :-
A1 == min, A2 = max -> A3 = unique;
A1 == min -> A3 = min; A2 == min -> A3 = min;
A1 == max -> A3 = max; A2 == max -> A3 = max;
A3 = single
A3 = any
).