CSE 230: Principles of Programming
Languages
A Prolog Cut Example
awk% bp
BinProlog 4.00 Copyright (C) Paul Tarau 1992-1995
by FTP from: clement.info.umoncton.ca
E-MAIL to : binprolog@info.umoncton.ca
(C-ified standalone)
(with heap GC enabled)
Finished loading system C-code (23203 instructions).
Finished loading user C-code (4 instructions).
?- consult(a).
% using compile/1 is MUCH faster
consulting(a.pl)
consulted(a.pl,time(0))
yes
?- a(X).
X=2;
no
?-
Prolog execution halted(0). CPU time = 0.50s
awk% awk%
Now a trace of the computation that was done here:
awk% bp
BinProlog 4.00 Copyright (C) Paul Tarau 1992-1995
by FTP from: clement.info.umoncton.ca
E-MAIL to : binprolog@info.umoncton.ca
(C-ified standalone)
(with heap GC enabled)
Finished loading system C-code (23203 instructions).
Finished loading user C-code (4 instructions).
?- consult(a).
% using compile/1 is MUCH faster
consulting(a.pl)
consulted(a.pl,time(0))
yes
?- trace(a(X)).
Call: a(_2244) : ;
!!! dynamic(a/1)
Call: b : ;
!!! dynamic(b/0)
CUT
Call: c : ;
!!! dynamic(c/0)
Call: fail : ;
!!! compiled(fail/0)
Fail: fail
Fail: c
Fail: b
Call: e : ;
!!! dynamic(e/0)
Exit: e
Exit: a(2)
X=2;
Redo: a(2)
Redo: e
Fail: e
Fail: a(_2244)
no
?-
Prolog execution halted(0). CPU time = 0.33s
awk%
To CSE 230 notes page
To CSE 230 homepage
Maintained by Joseph Goguen
© 2000, 2001, 2002 Joseph Goguen
Last modified: Thu Feb 28 20:31:00 PST 2002