Anonymous user
Currying: Difference between revisions
m
→{{header|REXX}}: added whitespace, changed some comments, used a template for the output sections.
Mercerenies (talk | contribs) (Latitude language added) |
m (→{{header|REXX}}: added whitespace, changed some comments, used a template for the output sections.) |
||
Line 1,468:
This example is modeled after the '''D''' example.
===specific version===
<lang ress>/*REXX program demonstrates a REXX currying method to perform addition. */
say 'add 2 to 3: ' add(2
say 'add 2 to 3 (curried):' add2(3)
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
add: procedure; $= arg(1); do j=2 to arg(); $= $ + arg(j); end; return $
add2: procedure; return add( arg(1), 2)</lang>
{{out|output|text= when using the defaults:}}
<pre>
add 2 to 3: 5
Line 1,482:
===generic version===
<lang rexx>/*REXX program demonstrates a REXX currying method to perform addition. */
say 'add 2 to 3: ' add(2
say 'add 2 to 3 (curried):' add2(3)
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
add: procedure; $= 0; do j=1 for arg()
do k=1 for words( arg(j) ); $= $ + word( arg(j), k)
end /*k*/
end /*j*/
return $
/*──────────────────────────────────────────────────────────────────────────────────────*/
add2: procedure; return add( arg(1), 2)</lang>
=={{header|Ruby}}==
|