Reputation: 1
I have some problem with trying to work out my code here.
Let's say I have these codes:
university('University of Cambridge', 1, 'United Kingdom', 90.3, 92.8, 89.4),
university('University of Oxford', 2, 'United Kingdom', 88.9, 94.8, 88.0).
How do I list out the names of the universities only? I tried doing listing. and listing(university). but that list out everything or the rules.
Trying to only get the names like:
University of Cambridge
University of Oxford
Upvotes: 0
Views: 180
Reputation: 2935
This gives you one name:
?: university(X,_,_,_,_).
You can query for more with ;
or space
To print all of them, you could use a fail driven loop:
?: university(X,_,_,_,_), write(X), nl, fail; true.
Upvotes: 2