-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement aggregates #10
Comments
That sounds interesting. What do you think would be a good syntax for aggregates?
Maybe something like the above? I think the only limitation is that it cannot be a valid expression syntax. |
My initial idea was to allow them in the same place as relations as clauses but with lowercase identifiers.
Special binding syntax One issue with that would be though that it's hard to bind the result of that to a variable. However, since all those aggregates return numeric values (ignoring the Your example then could look like this: crepe! {
@input
struct A(i32, i32);
@output
struct B(i32, i32);
B(x, n) <- n = max(x) { A(x, _) };
} Pro:
Con:
Out parameters I am not super convinced about starting with an assignment because that might be confusing when to use crepe! {
@input
struct A(i32, i32);
@output
struct B(i32, i32);
B(x, n) <- max(x, n) { A(x, _) };
} Pro:
Con:
Special casing Maybe to keep the syntax "clean" the right hand side expression for // aggregate
let n = max(x) { A(x, _) },
// user defined functions `max`
let n = max(x), Pro:
Con:
|
It would be nice to have aggregates in crepe. I am trying to do Advent of Code this year with as much crepe as I can and I ran into some situation where having them would have been nice.
The small set of aggregates that Soufflé has seems already really nice and powerful.
I am still learning to use Datalog, so I am very green when it comes to the implementation that crepe uses, but in general I would still be up to contribute this with some guidance. 🙃
The text was updated successfully, but these errors were encountered: