RosettaCodeData/Task/Partial-function-application/REXX/partial-function-application.rexx

24 lines
1.5 KiB
Rexx
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
/*REXX program demonstrates a method of a partial function application. */
s=; do a=0 to 3 /*build 1st series of some low integers*/
s=strip(s a) /*append to the integer to the S list*/
2014-01-17 05:32:22 +00:00
end /*a*/
2015-11-18 06:14:39 +00:00
call fs 'f1',s; say 'for f1: series=' s", result=" result
call fs 'f2',s; say 'for f2: series=' s", result=" result
2014-01-17 05:32:22 +00:00
2015-11-18 06:14:39 +00:00
s=; do b=2 to 8 by 2 /*build 2nd series, low even integers. */
s=strip(s b) /*append to the integer to the S list*/
2014-01-17 05:32:22 +00:00
end /*b*/
2015-11-18 06:14:39 +00:00
call fs 'f1',s; say 'for f1: series=' s", result=" result
call fs 'f2',s; say 'for f2: series=' s", result=" result
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
f1: return arg(1)* 2
2014-01-17 05:32:22 +00:00
f2: return arg(1)**2
2015-11-18 06:14:39 +00:00
/*────────────────────────────────────────────────────────────────────────────*/
fs: procedure; arg f,s; $=; do j=1 for words(s); z=word(s,j)
2014-01-17 05:32:22 +00:00
interpret '$=$' f"("z')'
end /*j*/
2015-11-18 06:14:39 +00:00
return strip($)