1

I found this inequality solving program from some Internet source.It works well.This is the program.

:-use_module(library(clpq)).

dec_inc(Left,Right):-
   copy_term(Left-Right,CopyLeft-CopyRight).
   tell_cs(CopyLeft).
   max(CopyRight,Right,Leq).
   tell_cs(Leq).

max([],[],[]).
max([E=<_|Ps],[_=<P1|P1s],[K=<P1|Ls]):-
   sup(E,K),
   max(Ps,P1s,Ls).

tell_cs([]).
tell_cs([C|Cs]):-                                   
   {C},
   tell_cs(Cs).

The problem I have regarding this program is when I run the program using capital letter variable it works.But it doesn't work for simple letter variables.

This is the syntax i used to solve this problem.

eg:-

{2*X+3>=5}.

This works and gives the correct answer.

{2*x+3>=5}.

When i run this, Prolog says

ERROR: Unhandled exception: nf(y,_G3082): argument 1 must be a a numeric expression

I'm using SWI-Prolog version 6.6.0.What is the problem here and how can I solve it.

false
  • 10,182
  • 12
  • 93
  • 182
ict
  • 105
  • 1
  • 5
  • 1
    Strings in Prolog that start with lower case are not variables. They are atoms. Specifically, `x` is not a number, but the atom, `'x'`, thus the error. Consult the Prolog documentation or a tutorial regarding Prolog fundamentals. – lurker Jan 12 '15 at 17:40
  • possible duplicate of [Print a value from a fact in Prolog?](http://stackoverflow.com/questions/23644500/print-a-value-from-a-fact-in-prolog) – Mostowski Collapse Aug 18 '15 at 09:09

0 Answers0