-
Notifications
You must be signed in to change notification settings - Fork 48
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
Built-in list functions do not allow variable argument lists #26
Comments
I have taken the liberty of implementing all the new built-in list functions added in DMN Feel 1.2 (mean, median, mode, stddev, product, and sublist) as well as fixing the issue of allowing variable argument lists.
Here is the code (which passes the lint checks). It is the contents of file: utils\built-in-functions\list-functions\index.js
|
I have changed most list functions. But to keep this module with DMN v1.1 I have not added the v1.2 built-in functions. But there is an alternative way of still importing those functions without touching this code base. I have explained the process in the next issue opened by you. There is one problem that stands out - the standalone usage of PS: the changes may come in over this week or the next. |
The built-in list functions max, min, sum and mean currently only accept a single argument, a list of items to be aggregated.
The DMN 1.2 specification, section 10.3.4.4 permits a flattened list of arguments of arbitrary length to be supplied instead of a list.
For example both these should work:
The following proposed change to utils\built-in-functions\list-functions\index.js would accomplish this.
Replace min, max, sum, and mean imlementations with this:
NOTE on aggregateHelper:
This function works around the implementation details. The context object is passed to all these methods as a hidden extra argument. By using the rest operator to get all arguments (since the arguments variable is not available in a lambda function) we are also slurping up that context, if present. This function checks for the context and removes it from the arguments to be passed on to lodash.
The text was updated successfully, but these errors were encountered: