It's one of my classroom question.
I was able to create my own Prolog program with bunch of if-else but I was told that my program is not fully declarative as its one of the very foundation principle in Prolog.
Here's my code
%start with :- go.
is_spicy :-
write('Do you want spicy? (yes/no)'),
read(Preference),
( Preference == yes -> recommend("Curry"); recommend("Kurma") ).
is_fry :-
write('Do you want fry food? (yes/no)'),
read(Preference),
( Preference == yes -> recommend("StirFry"); recommend("Chicken") ).
is_chili :-
write('Do you want chili? (yes/no)'),
read(Preference),
( Preference == yes -> recommend("Sambal"); recommend("Singgang") ).
recommend(Food) :- write('We recommend you '), write(Food).
go :-
write('Which food type do you prefer? (indian, chinese, malay): '),
read(FoodType),
(
FoodType == indian -> is_spicy;
FoodType == chinese -> is_fry;
FoodType == malay -> is_chili;
writeln('Please try again')
).
Anyone has any idea on how to make it "fully declarative"?