Flix (programming language): Difference between revisions

Content deleted Content added
JorKadeen (talk | contribs)
JorKadeen (talk | contribs)
Line 66:
=== Higher-Order Functions ===
 
The following program fragment defines a [[higher-order function]] <code>twice</code> that when given a function <code>f</code> from <code>Int</code> to <code>Int</code> returns a new function that applies <code>f</code> two times to its argumentinput two times:
 
<syntaxhighlight lang="Scala">
Line 72:
</syntaxhighlight>
 
TheWe can use the function <code>twice</code> function can be used as follows:
 
<syntaxhighlight lang="Scala">
def inctwice(x: Int): Int =-> x + 1)(0)
 
def two(): Int = twice(inc)(0)
</syntaxhighlight>
 
Here the call to <code>twice(x -> x + 1)</code> returns a function that will increment its argument two times. Consequently, the result of the entire expression is <code>0 + 1 + 1 = 2</code>.
 
=== Extensible Records ===