Currying: Difference between revisions
Content added Content deleted
Line 920: | Line 920: | ||
{{FormulaeEntry|page=https://formulae.org/?script=examples/Currying}} |
{{FormulaeEntry|page=https://formulae.org/?script=examples/Currying}} |
||
'''Solution''' |
|||
In Fōrmulæ, a function is just a named lambda expression, and a function call is just a lambda application. |
|||
The following is a simple definition of a lambda expression: |
|||
[[File:Fōrmulæ - Currying 01.png]] |
|||
When a lambda application is called with the same number of arguments, the result is the habitual: |
|||
[[File:Fōrmulæ - Currying 02.png]] |
|||
[[File:Fōrmulæ - Currying 03.png]] |
|||
However, if a less number of parameters is applied, currying is performed. Notice that the result is another lambda expression. |
|||
[[File:Fōrmulæ - Currying 04.png]] |
|||
[[File:Fōrmulæ - Currying 05.png]] |
|||
Because the result is a lambda expression, it can be used in a lambda application, so we must get the same result: |
|||
[[File:Fōrmulæ - Currying 06.png]] |
|||
[[File:Fōrmulæ - Currying 03.png]] |
|||
Using functions: |
|||
[[File:Fōrmulæ - Currying 07.png]] |
|||
[[File:Fōrmulæ - Currying 08.png]] |
|||
=={{header|GDScript}}== |
=={{header|GDScript}}== |