[m-users.] Recursive tabled predicates with aggregates / default compare

Mark Clements (gmail) samuel.legotus at gmail.com
Fri Aug 13 23:09:28 AEST 2021


As a summer project, I have been comparing Mercury, Datalog (Souffle) 
and Prolog for some small tasks.

I had an off-line discussion (a university spam filter prevented my 
joining the list:) with Zoltan about (1) sets vs bags for aggregates and 
(2) using aggregates within recursive tabled predicates. For (1), I have 
found that bag semantics lead to nice code for querying data. For (2), I 
note that these *are* allowed within Mercury (which is quite cool). For 
an example of (1) and (2), I have implemented a discrete time cyclic 
Markov model in Mercury and the other languages; see 
https://github.com/mclements/rosetta/tree/main/markov and 
https://github.com/mclements/rosetta/tree/main/markov#collapse-transitions-by-time-and-state-1.

I have also been looking at the RosettaCode task 
https://rosettacode.org/wiki/Merge_and_aggregate_datasets for Mercury. I 
have an implementation here: 
https://github.com/mclements/rosetta/tree/main/Merge_and_aggregate_datasets. 
Interestingly, the dates need to also allow for missing values. As a 
question: if maybe_date is defined as

`:- type maybe_date ---> date(year::int, month::int, day::int); no.`

what is the default definition for 
`compare(Compare,date(Y1,M1,D1),date(Y2,M2,D2))`?

Kindly, Mark.

PS: it was easier to join the list through a shared Google account, 
hence the odd email address. My usual email address is mark.clements at ki.se.




More information about the users mailing list