Home > Archive > Prolog > December 2004 > cut in SWI-Prolog
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I have two queries:
a) ?- G = (member(X, [a, b]), !, write(X)), call(G).
b) ?- G = (member(X, [a, b]), call(!), write(X)), call(G).
My question is: what is the difference between scope of "!" in (a) and
(b) in these queries (as in both of them G is metacalled) ?
| |
| Nick Wedd 2004-12-01, 3:58 pm |
| In message <9abc3ca2.0412010438.7f2f4e94@posting.google.com>, Budyn
<budyn@zamek.gda.pl> writes
>I have two queries:
>
>a) ?- G = (member(X, [a, b]), !, write(X)), call(G).
>
>b) ?- G = (member(X, [a, b]), call(!), write(X)), call(G).
>
>My question is: what is the difference between scope of "!" in (a) and
>(b) in these queries (as in both of them G is metacalled) ?
You can see the same effect more simply with
?- member(X, [a, b]), !, write(X).
which just has one solution, and
?- member(X, [a, b]), call(!), write(X).
which is resatisfiable.
"!" cuts back to the call (or redo) of the predicate which contains it.
In
?- G = (member(X, [a, b]), !, write(X)), call(G).
this is call(G). In
?- member(X, [a, b]), !, write(X).
it is the command-line query. In
?- G = (member(X, [a, b]), call(!), write(X)), call(G).
and
?- member(X, [a, b]), call(!), write(X).
it is the call to 'call'.
Nick
--
Nick Wedd nick@maproom.co.uk
|
|
|
|
|