Currying: Difference between revisions

Latitude language added
(Latitude language added)
Line 1,001:
2 + 3 = 5
</pre>
 
=={{header|Latitude}}==
 
<lang>addN := {
takes '[n].
{
$1 + n.
}.
}.
 
add3 := addN 3.
add3 (4). ;; 7</lang>
 
Note that, because of the syntax of the language, it is not possible to call <code>addN</code> in one line the naive way.
<lang latitude>;; addN (3) (4). ;; Syntax error!
;; (addN (3)) (4). ;; Syntax error!
addN (3) call (4). ;; Works as expected.</lang>
 
As a consequence, it is more common in Latitude to return new objects whose methods have meaningful names, rather than returning a curried function.
<lang latitude>addN := {
takes '[n].
Object clone tap {
self do := {
$1 + n.
}.
}.
}.
 
addN 3 do 4. ;; 7</lang>
 
=={{header|LFE}}==
37

edits