Currying: Difference between revisions

m
→‎{{header|REXX}}: added whitespace, changed some comments, used a template for the output sections.
(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 , 3)
say 'add 2 to 3 (curried):' add2(3)
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────subroutines─────────────────────────*/
add: procedure; $= arg(1); do j=2 to arg(); $= $ + arg(j); end; return $
add2: procedure; return add( arg(1), 2)</lang>
{{out|output|text=&nbsp; when using the defaults:}}
{{Out}}
<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 , 3)
say 'add 2 to 3 (curried):' add2(3)
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────ADD subroutine──────────────────────*/
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 subroutine─────────────────────*/
add2: procedure; return add( arg(1), 2)</lang>
'''{{out|output'''|text=&nbsp; is theidentical same asto the 1<sup>st</sup> REXX version.}} <br><br>
<br><br>
 
=={{header|Ruby}}==