Please send questions to
st10@humboldt.edu .
a few words on cut:
!
(type a cut as !)
* ! is a goal that always succeeds, BUT has side effects that
prevent it from being able to be backtracked over;
Clocksin and Mellish give 3 "common uses" of cut:
(pp. 64-78)
* first - "we want to tell the Prolog system that it has found
the RIGHT rule for a particular goal"
says: "if you get this far, you have picked the CORRECT rule for
this goal"
* second (when cut is used with fail/0):
"we want to tell the Prolog system to fail a particular
goal immediately, WITHOUT trying for alternative solutions"
says: "if you get to here, you should STOP trying to satisfy this
goal"
* third: "we want to terminate the generation of alternative
solutions through backtracking"
says: "if you get to here, you have found the only solution
to this problem, and there is no point in ever looking for
alternatives"
foo :- a, b, c, !, d, e, f.
(source: Pomona tutorial)
* green cut: a cut that is JUST to improve efficiency
* red cut: to restrict answers; to block what what would
otherwise be reported as consequences of the program