Miranda (programming language): Difference between revisions

Content deleted Content added
m c/e
Overview: Use available symbols (words).
Tags: Mobile edit Mobile web edit
Line 86:
The notation for function application is simply juxtaposition, as in <code>sin x</code>.
 
In Miranda, as in most other purely functional languages, functions are [[first-class function|first-class]] citizens, which is to say that they can be passed as [[parameter (computer science)|parameterarguments]]s to other functions, returned as results, or included as elements of data structures. What is more, a function requiringwith two or more parameters may be "partially parameterised", or [[currying|curried]], by supplying fewer arguments than the full number of parameters. This gives another function which, given the remaining parameters, will return a result. For example:
 
<syntaxhighlight lang="haskell">
Line 95:
is a roundabout way of creating a function "increment" which adds one to its argument. In reality, <code>add 4 7</code> takes the two-parameter function <code>add</code>, applies it to <code>4</code> obtaining a single-parameter function that adds four to its argument, then applies that to <code>7</code>.
 
Any function takingwith two parameters (operands) can be turned into an infix operator (for example, given the definition of the <code>add</code> function above, the term <code>$add</code> is in every way equivalent to the <code>+</code> operator) and every infix operator taking two parameters can be turned into a corresponding function.
Thus: