Other control constructs can sometimes be more efficient, but can sometimes cause loss of readability:
or - THIS ; THAT
if-then-else - COND -> THEN ; ELSE
price(apple, 10). price(orange, 10).
?- price(X, 10). X = apple ; X = orange ; no
price(X, 10) :- ( X = apple ; X = orange ).
?- price(X, 10). X = apple ; X = orange ; no
price(apple, 10). price(orange, 20).
?- price(orange, X). X = 20 yes
price(Item, Price) :-
( Item = apple ->
Price = 10
;
(Item = orange ->
Price = 20
;
fail)
).
?- price(orange, X). X = 20 yes