Code Comments
Programming Forum and web based access to our favorite programming groups.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) ?
Post Follow-up to this messageIn 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.