如何在menu1/0
出现后让程序继续false
mylist([a,b,c]).
myprog(X) :- mylist(L), member(X, L).
go :- start_message,menu1.
start_message :-
write('This is a program.'),nl,
write('Below are a list:'),nl,
myprog(X),
write(X),nl,
fail.
menu1 :-
nl,write('Select operation:'),nl,
write('1. Input time'),nl,
write('2. Exit program'),nl.
以下是我的观点:
go.
This is a program.
Below are a list:
a
b
c
false
答案 0 :(得分:1)
你可以这样做
start_message :-
write('This is a program.'),nl,
write('Below are a list:'),nl,
( myprog(X),
write(X),nl,
fail
; true ).
现在myprog/1
不能再成功,控制权转到true/0
,start_message/0
成功。
答案 1 :(得分:0)
删除fail
的最后一行中的start_message
语句。