Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to state Var > 0?

Status
Not open for further replies.

ice128

Programmer
Nov 4, 2008
3
AT
i need to state in prolog that memb[index][addr] > 0

I write:

Val >= 0 :-
memb(Index, Addr, Val).

But swi prolog says: ERROR No permission to modify static_procedure `(>=)/2'

What is workaround of this mistake? Thank you.
 
memb[index][addr] means nothing in Prolog.

You can't write
Val >= 0 :-
memb(Index, Addr, Val).
because in Prolog before :- is the head of the rule and after is the body.
The head of the clause must either aaa :- or aaa(X) :- or aaa(X,Y) :- or ...
 
Do I need to define own implication => and state:

memb(Index, Addr, Val) => Val >= 0.

?
 
You can write
memb(Index, Addr, Val) :- Val >= 0.
This means that memb(Index, Addr, Val) succeeds if Var >= 0.
At compile-time you will have a warning about Index and Addr baecause they arne not used. To avoid this w<arningyou can write
memb(_Index, _Addr, Val):- Val >= 0.

 
Sorry, but I need to state reverse implication:
Val >=0 <= memb(Index, Addr, Val).

It is like type definition in C language. If Val is type DWORD then it is higher then 0. I'm trying to state type of memb.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top