I'm very new to Prolog myself, but I hope can help. First, as a note about wording, Prolog doesn't really "return" anything. You have goals that either succeed or fail. That being said, when you pass in a parameter that is an ununified variable (the variable has not been bound to anything), then it will attempt to find a correct value for that variable. If successful, it will seem to "return" the value. If the goal fails, then you will receive a "false" or "no" (I believe the two mean the same thing and just depend on what version of Prolog you're using).
As lurker noted in his/her comment, the answer might depend on in what form your professor wants you to present the food that's going to be served. You could take lurker's suggestion to make X a list or custom term (I'm not familiar with the latter). Or, another way to do this would be:
(I corrected your spelling of "entree," it was just personally irking me)
/* facts */
entree(lunch, sandwich).
entree(dinner, spaghetti).
side(lunch, chips).
side(dinner, bread).
drink(lunch, lemonade).
drink(dinner, water).
/* rules */
meal(X, Y) :- entree(X, Y).
meal(X, Y) :- side(X, Y).
meal(X, Y) :- drink(X, Y).
When you call your predicate, sometimes there are multiple possible values for the variable whose values you're looking for. In this case, once the first value for your variable has been found, you should have the option to enter the semicolon to continue searching for the rest until there are no more possible values. This may be one way of "returning" multiple values.
Now, if you call meal(lunch, Y).
this will first find Y to be "sandwich". You've gotten to the first rule and found a value for Y, since an entree for lunch is sandwich. Once you press ;, it'll continue to try to find more values for Y. For the first rule there are no more values for Y--there's only one entree for lunch, though if you added more (e.g. entree(lunch, pasta).
) it would find more entrees. It'll continue to the second rule and try to find the side for Y, then afterward the drink for Y, etc, in exactly the same manner. Using the above code:
?- meal(lunch, Y).
Y = sandwich ;
Y = chips;
Y = lemonade;
entry(lunch, X)
and you'll getX = sandwich
, so the call "returns"X = sandwich
. When you callmeal(lunch, X)
,meal/2
can succeed with one or more different instantiations ofX
. In this particular case, it sounds likeX
should define a whole meal, in which case it could be either a list (for example,[sandwhich, chips, lemonade]
or a custom term, such asservings(sandwich, chips, lemonade)
. Your choice. – lurker