Prolog FindAll with a range of particular values

Viewed 66

I am attempting to use findall, but I want one of the values of the argument to be a range of values. I have seen another post utilizing 'between' but I can't seem to get it to work. This is the code I want to alter:

lists(A):-
    findall(X,gradrate(2011,_,X),A).

I want essentially:

lists(A):-
    findall(X,gradrate(2011-2015,_,X),A).

Basically I want a list of all the graduation rates between years 2011 and 2015. I have a bunch of facts already written with all the gradrates I.E

gradrate(2011,asian,85.6).

Any point in the right direction would be awesome, thanks!

1 Answers

Try:

lists(A):-
    findall( X, 
             ( gradrate(Year, _, X),
               between(2011, 2015, Year) ),
             A ).
Related