|
You can very often rewrite uses of the cut like: foo(X, Y) :-
some_condition(X),
!,
bar(Y, X).
foo(X, Y) :-
baz(X, Y).
to: foo(X, Y) :-
( some_condition(X)
-> bar(Y, X)
; baz(X, Y) ).
and get the same performance and clearer code.There are really very few actually useful uses of the cut in modern Prolog code. But we have no good, free, current teaching materials, so people get stuck learning the old ugly and convoluted ways. |
Unfortunately since it's almost impossible to model ideas without stuff like the arrow, cut, or \+ (not) operators, writing actual pure logical Prolog programs that actually do interesting things is supremely difficult.