Prolog - Listing -


i have problem trying work out code here.

let's 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 list out names of universities only? tried doing listing. , listing(university). list out or rules.

trying names like:

university of cambridge university of oxford 

this gives 1 name:

?: university(x,_,_,_,_). 

you can query more ; or space

to print of them, use fail driven loop:

?: university(x,_,_,_,_), write(x), nl, fail; true. 

Comments