Skip to content
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 maximum and minimum aggregation function #52

Closed
denismerigoux opened this issue Jan 4, 2021 · 3 comments · Fixed by #56
Closed

Implement maximum and minimum aggregation function #52

denismerigoux opened this issue Jan 4, 2021 · 3 comments · Fixed by #56
Labels
🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request ❓ invalid This doesn't seem right

Comments

@denismerigoux
Copy link
Contributor

denismerigoux commented Jan 4, 2021

Catala supports maximum and minimum aggregation functions for collections. Right now, these are only present in the surface syntax.

One has to fill the holes like this one :

| Ast.Aggregate (Ast.AggregateExtremum _) ->
Errors.raise_spanned_error "Unsupported feature: minimum and maximum"
(Pos.get_position op')

To do that, the expression maximum money for salary in salaries of (salary - $200) should desugar to

fold (fun acc salary -> let tmp = (salary - 200) in if acc < tmp then tmp else acc) <INIT> salaries

The problem lies within the <INIT> expression. What to put here? I guess this should be provided by the user, so we have to update the syntax to something like maximum money context $0 for salary in salaries of (salary - $200)

@denismerigoux denismerigoux added ✨ enhancement New feature or request ❓ invalid This doesn't seem right 🔧 compiler Issue concerns the compiler labels Jan 4, 2021
@nchataing
Copy link
Collaborator

What should the extremum of an empty collection returns ? If it raises an error, then we could take any element of the collection for the <INIT> expressions.

@denismerigoux
Copy link
Contributor Author

In case of an empty collection, it should return <INIT> precisely, that's why we need an <INIT>

@denismerigoux
Copy link
Contributor Author

I'm not confortable with forcing collections to be non-empty. Then it would force us to wrap collections in option types, which is cumbersome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request ❓ invalid This doesn't seem right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants