[x] PR title descriptive (can be used in release notes)
Description
Adds a new function available in all @calc() blocks: merge_sub_arrays(). This is a hack to expose some particular array manipulation logic to authors, for a specific purpose in the upcoming plh_facilitator_my deployment release.
merge_sub_arrays() takes 3 arguments: an array of arrays (expected to be a partition of a set) and 2 values that appear in sub-arrays. The function looks for the sub-array containing one value and merges it with the sub-array containing another, returning a mutation of the original partition. See screenshots and debug sheets below for usage.
However, this approach does not work as the evaluated string from @calc() gets returned in the resulting javascript, so additional functions cannot be defined. Further thought is required to enable authors to write functions in data lists and call them in @calc() blocks, see #2121.
PR Checklist
Description
Adds a new function available in all
@calc()
blocks:merge_sub_arrays()
. This is a hack to expose some particular array manipulation logic to authors, for a specific purpose in the upcomingplh_facilitator_my
deployment release.merge_sub_arrays()
takes 3 arguments: an array of arrays (expected to be a partition of a set) and 2 values that appear in sub-arrays. The function looks for the sub-array containing one value and merges it with the sub-array containing another, returning a mutation of the original partition. See screenshots and debug sheets below for usage.Notes
I initially tried writing the function in a data list and referring to it in a
@calc()
block. See debug_functions_data_list and debug_calc_functionsHowever, this approach does not work as the evaluated string from
@calc()
gets returned in the resulting javascript, so additional functions cannot be defined. Further thought is required to enable authors to write functions in data lists and call them in@calc()
blocks, see #2121.Git Issues
Closes #
Screenshots/Videos
See debug_calc_functions template for usage