The predicate that I want to implement, I need you to do the following:
predicado(Máximo,Num1,Num2).
And you must return two numbers Num1 and Num2 fulfilling that:
- Num1 < Num2
- Num2
The predicate that I want to implement, I need you to do the following:
predicado(Máximo,Num1,Num2).
And you must return two numbers Num1 and Num2 fulfilling that:
You simply need a function that generates a range of numbers by re-evaluation:
ran(X,Y,X) :- X < Y.
ran(X,Y,Z) :- X < Y, X2 is X+1, ran(X2,Y,Z).
Now you can implement your predicate based on two ranges:
1
to maximum ( X+1
), which will be the second number ( Z
) 1
to Z
, which will be the first number ( Y
) That is:
p(X,Y,Z) :- X2 is X+1, ran(1,X2,Z), ran(1,Z,Y).