Documentation on -> operator
The tutorial uses at one point the -> operator.
# Finding most popular name for each year.
@OrderBy(TopNameByYear, "year");
TopNameByYear(year) ArgMax= name -> NameCountByYear(name:, year:);
While this seems to be a variant on the functional aggregation method, it's not documented anywhere. Is there a more complete language reference that can be linked?
Thanks!
Thank you for bringing this up. We will create a reference to make looking up meaning of functions easier.
Meanwhile as for the "->" operator: it's just a streamlined syntax for writing structure {arg:, value:}. E.g. the program
Q("hello" -> "world");
results in a table:
| col0 |
|---|
| {'arg': 'hello', 'value': 'world'} |
Aggregating operator ArgMax takes in a single argument, which has to be a struct {arg:, value:}, it then finds an arg that has maximal value. So the program that you cited could be written as
# Finding most popular name for each year.
@OrderBy(TopNameByYear, "year");
TopNameByYear(year) ArgMax= {arg: name, value: NameCountByYear(name:, year:)};
Leaving the issue open, as we need formal documentation. Meanwhile let me know if you have further questions.
Awesome, that's helpful! I had seen that struct behavior happening but didn't realize that it was being caused directly by ->. That makes sense now, though doubles as a need for functions like ArgMax needing documentation (sooner or later) as well.