?? ch07ex06.pro
字號:
/*
Turbo Prolog 2.0 Chapter 7, Example Program 6
Copyright (c) 1986, 88 by Borland International, Inc
*/
/* Shows how badcount2 and badcount3 can be fixed by adding cuts to
rule out the untried clauses. These versions are tail recursive. */
predicates
cutcount2(real)
cutcount3(real)
check(real)
clauses
/* cutcount2:
There is a clause that has not been tried
at the time the recursive call is made. */
cutcount2(X) :-
X>=0, !,
write(X),
nl,
NewX = X + 1,
cutcount2(NewX).
cutcount2(_) :-
write("X is negative.").
/* cutcount3:
There is an untried alternative in a
clause called before the recursive call. */
cutcount3(X) :-
write(X),
nl,
NewX = X+1,
check(NewX),
!,
cutcount3(NewX).
check(Z) :- Z >= 0.
check(Z) :- Z < 0.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -