I have been exercising library(aggregate)
a bit, here are
- Notes
- Exercise data (the mtcars data set from R)
- Helper predicates
However, I have immediately hit a snag. avg
gives me a false.
?- aggregate(avg(M),C^car_cyl_mpg(C,M),R).
false.
The helper predicate car_cyl_mpg(C,M)
generates cylinder/miles-per-gallon tuples:
bagof([C,M],car_cyl_mpg(C,M),L).
L = [[6, 21.0], [6, 21.0], [4, 22.8], [6, 21.4], [8, 18.7], [6, 18.1], [8, 14.3], [4|...], [...|...]|...].
and it works for max
for example:
?- aggregate(max(M),C^car_cyl_mpg(C,M),R),unpump(R). % Same
Result: the value 33.9
R = 33.9.
Does anybody have a hint what’s going on?