[m-users.] Announcement (aggregates module) + questions (window functions)

Volker Wysk post at volker-wysk.de
Sat Dec 31 03:17:06 AEDT 2022


Thanks for sharing!

I've added it to my list of Mercury resources:

https://volker-wysk.de/mercury/resources.html#mark-clementss-aggregates-library

Cheers,
Volker


Am Donnerstag, dem 29.12.2022 um 13:27 +0000 schrieb Mark Clements:
> As an announcement, I have drafted a Mercury module for aggregates: see https://github.com/mclements/mercury-aggregates . This includes bag and set semantics for count, min, max, sum, avg, geom_mean, var, median and quantile.
> 
> As an extension, I have tried to implement window functions (https://en.wikipedia.org/wiki/Window_function_(SQL)) in Mercury: see https://github.com/mclements/mercury-aggregates/blob/main/test_window.m for an example. First, has anyone previously worked with window functions in Mercury? Second, is the syntax that I have used sensible (see code snippet below)? Here, bag_cum_sum and bag_row_number are functions that return a predicate, which is concise, but perhaps not obvious.
> 
> %% patient and visit are nondet predicates
> main(!IO) :-
>     print_line("{Id, RowNumber, Date, Score, CumScore}", !IO),
>     aggregate((pred({Id,RowNumber,Datei,Scorei,CumScorei}::out) is nondet :-
>                    patient(Id,_),
>                    Combined = (pred(Date::out,Score::out) is nondet :- visit(Id,Date,Score)),
>                    Combined(Datei,Scorei),
>                    bag_cum_sum(Combined)(Datei,CumScorei),
>                    Dates = (pred(Date::out) is nondet :- Combined(Date,_)),
>                    bag_row_number(Dates)(Datei,RowNumber)),
>               print_line,
>               !IO).
> 
> Third, I have sought to stay with nondet predicates, with the implementation internally using lists -- is there a better approach?
> 
> Sincerely, Mark.
> 
> 
> När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI kommer att behandla dina personuppgifter. Här finns information om hur KI behandlar personuppgifter<https://ki.se/medarbetare/integritetsskyddspolicy>.
> 
> 
> Sending email to Karolinska Institutet (KI) will result in KI processing your personal data. You can read more about KI’s processing of personal data here<https://ki.se/en/staff/data-protection-policy>.
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20221230/4a1ad383/attachment.sig>


More information about the users mailing list