Higher order functions take a table of data or array and apply a lambda function to transform the data into a new array.
This could be to format the existing data or to apply detailed filtering.
Higher order functions take the following arguments:
Depending on the function used the following arguments may also be required:
The input array argument requires an array that the Lambda will iterate over to produce the new array.
Typically this would be a Table, but could also come from a control (such as a Data Table) or another function that results in an array.
DriveWorks automatically converts table data into an array format, for example:
{"A","B","C";"A1","B1","C1";"A2","B2","C2"}
This is the Lambda function that will be applied to the array.
The exact name of the Function argument depends on the type of higher order function being used.
For functions that apply detailed filtering of the array this will be a Filter Function.
See the following for more information:
For functions that transform the array this will be a Decorator Function.
See the following for more information:
When building the rule and the function is expecting the Filter or Decorator Function, rules insight will display the Input Array Values required for the Lambda.
A DWLambda function can be added to the rule by:
Parameters
The names given to the parameters inserted from rules insight are indicative of the value being returned.
Names can be changed to a more descriptive reference. The modified name will then be used in the function.
For example, the decorator function for TableMap could be changed to be:
DWLambda( InchValue, InchValue*25.4 )
We recommend only using pure functions in the provided DWLambda function.
A function is considered pure when:
A function is considered impure when:
Please observe the following when constructing the DWLambda for the function argument.
This will ensure no unexpected errors are encountered and the higher order function performs optimally.
The rule will return an Invalid Rule error if this is used.
Applies to TableFilterByFunction.
This targets the column the Filter Function will check for a match.
Input Arrays are assumed to include a header row by default.
This argument is only required to be set if the values in the first row are not headers and are in fact values that are required to be affected by the function.
Set this argument to TRUE if the Input Array does not have a header row.
Applies to TableMap.
Lazy Evaluation is only applied when a Specification is run.
When building a TableMap rule all values in the array are evaluated and can be seen in real time in Table Visualization (in the Drill Down tab of the Rule Builder).
When Enable Lazy Evaluation is TRUE any cell evaluations will be calculated only when that cell is accessed.
For example, the following rule calls a cell in a TableMap function where Lazy Evaluation Enabled is TRUE:
TableGetValue(DWVariableTableMap,2,7)
The TableMap function will only evaluate the cell (referenced by Column Index 2 and Row Index 7) in the result.
When Enable Lazy Evaluation is FALSE the evaluation of each cell is conducted immediately when the function is called and then stored.
Lazy Evaluation may require to be disabled due to:
DWLambda - Allows custom, reusable functions to be created.
TableMap - Applies a Lambda Function across a provided array and returns a new array with the result of the Lambda function applied.
TableFilterByFunction - Filters an array based on a single column using the provided Lambda Function.
TableFilterByRowFunction - Filters an array using the provided Lambda Function applied to each row.