Interface 2


Program ask user and show possible answer

Source: Building Expert Systems in PROLOG Publisher


Program source code:


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,
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).


pl/prolog/pllib/interface_2.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna) Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0