Currying: Difference between revisions

jq
(jq)
Line 248:
alert(add2);
alert(add2(7));</lang>
 
=={{header|jq}}==
 
In jq, functions are filters. Accordingly, we illustrate currying by defining plus(x) to be a filter that adds x to its input, and then define plus5 as plus(5):
<lang jq>
def plus(x): . + 5;
 
def plus5: plus(5);
</lang>
 
We can now use plus5 as a filter, e.g.<lang jq>3 | plus5</lang> produces 8.
 
=={{header|LFE}}==
2,522

edits