Is there a way to do an if in prolog, e.g. if a variable is 0, then to do some actions (write text to the terminal). An else isn\'t even needed, but I can\'t find any docume
The best thing to do is to use the so-called cuts, which has the symbol !.
if_then_else(Condition, Action1, Action2) :- Condition, !, Action1.
if_then_else(Condition, Action1, Action2) :- Action2.
The above is the basic structure of a condition function.
To exemplify, here's the max function:
max(X,Y,X):-X>Y,!.
max(X,Y,Y):-Y=
I suggest reading more documentation on cuts, but in general they are like breakpoints.
Ex.: In case the first max function returns a true value, the second function is not verified.
PS: I'm fairly new to Prolog, but this is what I've found out.