There is a "hidden" section in the if-then-else Prolog construct:
abs2(X,Y) :- X < 0 -> Y is -X ; Y = X.
This is a bit of a quirk, but Prolog does not return to the subtitle that forms the "premise" of the if-then or if-then-else construct. Here, if X <0 succeeds on the first attempt, then the selection of the βthenβ clause over the else clause is performed (therefore, the description of this behavior as a βhiddenβ cut).
abs2/2, . , ( , , ). , , , , .
, , :
abs2(X,X) :- X >= 0, !.
abs2(X,Y) :- Y is -X.
"" ( ) "" .