Spis treści

Interface 2

Description

Program ask user and show possible answer

Source: Building Expert Systems in PROLOG Publisher

Download

Program source code: interface_2.pl

Listing

size(X):- menuask(size, X, [large, plump, medium, small]).
flight(X):- menuask(flight, X, [ponderous, agile, flap_glide]).
 
menuask(A, V, MenuList) :-
write('What is the value for'), write(A), write('?'), nl,
write(MenuList), nl,
read(X),
check_val(X, A, V, MenuList),
asserta( known(yes, A, X) ),
X == V.
 
check_val(X, A, V, MenuList) :-
member(X, MenuList), !.
 
check_val(X, A, V, MenuList) :-
write(X), write(' is not a legal value, try again.'), nl,
menuask(A, V, MenuList).

Comments