Christophe
Christophe

Reputation: 43

Prolog Arithmetic plus

I've stumbled on a rather weird problem (to me).

Very easy, I want to an addition between 2 integers. I use the plus clause from swi

Now when I do this (I'm calculation something in a graph)

plus(LatestTime,LengthPath,TimeArrive),

The TimeArrive variable is a physical address instead of the answer. Now I've tried to make an other clause

myPlus(Var1,Var2,Result):-
    Result is Var1 + Var2.

And here is the same, so I'm starting to believe their is something wrong with my 2 input variables

LatestTime,LengthPath

However when I 'write' them I receive the integer instead of physical address.

Any clues? Because I'm out of idea's :)

Upvotes: 2

Views: 430

Answers (1)

repeat
repeat

Reputation: 18726

Use for expressing relations between integer values whenever possible!

In general, I think it is best to use for all integer calculation instead of "plain-old Prolog arithmetics via (is)/2---not just the ones you consider "reversible".

Upvotes: 1

Related Questions