22.6 Key access: Answer
Answer for "Key access"
The suggested way of answering this is as follows:
key_access(X) :- stay(X,monday,Copenhagen). key_access(X) :- stay(X,tuesday,Odensee). key_access(Beth).
We have used a fact to state the fact that Beth had access to the key. We could also have used a rule:
key_access(X) :- eq(X, Beth).
but that wouldn't have been as elegant as just using a fact. It is Prolog's pattern matching which gives us the freedom to use a fact instead of a rule.
Prev: Weapon access
Up: 22 A Murder Mystery
Next: Crime access