Lambda¶
The Lambda node in Sympathy is like a subflow but when executing it the nodes inside are not executed directly. Instead they are packaged into a data type that is sent to the output port on the outside of the Lambda to be executed at a later time.
Lambdas can be used to reduce duplication, to work with nested lists, and allow for conditional execution of nodes. They are created by right-clicking on an empty area of a workflow and choosing Create Lambda. To execute the contents of the Lambda use either Apply or Map.
A Lambda has only a single output on the outside. The type of the output is a function with argument types depending on the types connected to the input ports on the inside.
Like with any other data type the output from Lambda can be used with any nodes that handle generic types, such as list or tuple operations. This enables some advanced use cases like putting Lambdas in lists to be executed using a Map node.
See also the nodes Extract Lambdas and Extract Flows as Lambdas for a way to import Lambda functions from workflow files.
Configuration data in Lambda¶
If input data is needed to properly configure the Lambda, the input ports can be shown on the outside of the Lambda by right-clicking on the lambda and selecting . These ports can then be used to connect data to be used for configuration. Note that this data is only used when configuring and will not be used when the Lambda is used with Apply or Map. To hide the input port, right click on the port and choose Delete.