.. This file is part of Sympathy for Data. .. .. Copyright (c) 2015 System Engineering Software Society .. .. Sympathy for Data is free software: you can redistribute it and/or modify .. it under the terms of the GNU General Public License as published by .. the Free Software Foundation, either version 3 of the License, or .. (at your option) any later version. .. .. Sympathy for Data is distributed in the hope that it will be useful, .. but WITHOUT ANY WARRANTY; without even the implied warranty of .. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .. GNU General Public License for more details. .. You should have received a copy of the GNU General Public License .. along with Sympathy for Data. If not, see . .. _higher_order_functions: Functions --------- Lambda creates a function that can be applied using :ref:`Apply` and :ref:`Map`. Furthermore :ref:`Extract Lambdas` can be used to obtain a list of Lambda. These can be used to reduce duplication, to work with nested lists. And allows for conditional execution of parts of components expressed as functions. To create these elements simply right-click on an empty area inside the subflow and choose *Create Lambda*. .. _lambda_function: Lambda function ^^^^^^^^^^^^^^^ There are two primary usecases for Lambdas: 1. sharing the same flow execution without repeating the flow structure, 2. being able to :ref:`Map`. over lists. Some advanced use-cases are possible using Lambdas, for example putting Lambda functions in lists to be executed using a :ref:`Map`. This section only covers the basics. There are two ways to use the output from Lambdas: 1, connect it to the :ref:`Apply` function, 2. connect it to the :ref:`Map` node. The output can also be put in lists using Item to List and other nodes that work with generic types, and finally it can be read from and written to files. If you want to create a new Lambda function simply right-click on an empty area inside the subflow and choose *Create Lambda*. A Lambda function 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 inputs. If input data is need to properly configure the Lambda, the input ports can be shown on the outside of the Lambda by right-clicking and selecting *Show Input Port -> Port[n]*. These ports can then be used to connect data to be used for configuration. Input ports shown on the outside can be removed by right-clicking and selecting *Delete Port*.