Currying: Difference between revisions

582 bytes added ,  11 years ago
+J
(→‎{{header|Tcl}}: Some more notes)
(+J)
Line 84:
increment call(5)
// result => 6</lang>
 
=={{header|J}}==
 
'''Solution''':Use <tt>&</tt> (bond). This primitive conjunction accepts two arguments: a function (verb) and an object (noun) and binds the object to the function, deriving a new function.
'''Example''':<lang j> threePlus=: 3&+
threePlus 7
10
halve =: %&2 NB. % means divide
halve 20
10
someParabola =: 1 3 _2 &p. NB. x^2 + 3x - 2</lang>
 
'''Note''': The final example (<tt>someParabola</tt>) shows the single currying primitive (&) combined with J's array oriented nature, permits partial application of a function of any number of arguments.
 
=={{header|Java}}==
Anonymous user