So my problem is the following:
I must create a list , using the findall / bagof / setof commands.
Here is my data file:
musico('R. Stevie Moore').
musico('Lane Steinberg').
musico('Yukio Yung').
musico('Jessie Evans').
musico('Bettina Koster').
musico('Lucia Pamela').
musico('Shooby Taylor').
musico('Tiny Tim').
musico('Bettina Koster').
musico('The Legendary Stardust Cowboy').
album('R. Stevie Moore', 'Manuscription').
album('Lane Steinberg', 'Manuscription').
album('R. Stevie Moore', 'The Yung & Moore Show').
album('Yukio Yung', 'The Yung & Moore Show').
album('Jessie Evans', 'Autonervous').
album('Bettina Koster', 'Autonervous').
album('Lucia Pamela', 'Walking on the moon').
album('Shooby Taylor', 'The Human Horn').
album('Tiny Tim', 'God Bless Tiny Tim').
album('The Legendary Stardust Cowboy', 'Rock-It to Stardom').
formato('Rock-It to Stardom',vinil).
formato('Walking on the Moon',vinil).
formato('God Bless Tiny Tim',cd).
formato('Walking on the Moon',cd).
formato('Autonervous',cd).
formato('Manuscription',cd).
formato('The Human Horn',cassete).
formato('The Yung & Moore Show',cassete).
formato('Walking on the Moon',mp3).
I must create a list containing all the musicians (musicos) that are associated with each album.
What i though was this:
all_musicians_album([Z]) :-
write('Write the name of the album : '),
read(Y),
findall(X, album(X,Y), Z).
The idea was to use the user input album on the album(X,Y) so that it would only find and add to the list musicians associated with that album.
This brought 2 problems which i cant seem to be able to solve:
- It doesnt work, the function adds all musicians to the list.
- It only works for one album each time the function is called.Is it possible to do this in a single function? Like saving the album and the musicians in a list than adding those lists to a single list? Or should i use bagof instead of findall?
Thank you for your help.