Nested function: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: simplified the code.)
m (→‎{{header|REXX}}: user the function name suggest by the task.)
Line 1,150: Line 1,150:
<lang rexx>/*REXX program demonstrates that functions can be nested (an outer and inner function).*/
<lang rexx>/*REXX program demonstrates that functions can be nested (an outer and inner function).*/
ctr= 0 /*initialize the CTR REXX variable.*/
ctr= 0 /*initialize the CTR REXX variable.*/
call makeList . /*invoke makeList with the separator.*/
call MakeList . /*invoke MakeList with the separator.*/
exit 0 /*stick a fork in it, we're all done. */
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
makeItem: parse arg sep,text; ctr= ctr + 1 /*bump the counter variable. */
makeItem: parse arg sep,text; ctr= ctr + 1 /*bump the counter variable. */
say ctr || sep word(string, ctr) /*display three thingys to the terminal*/
say ctr || sep word($, ctr) /*display three thingys ───► terminal. */
return
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
makeList: parse arg sep; string= 'first second third' /*get arguments; define a strong.*/
MakeList: parse arg sep; $= 'first second third' /*obtain an argument; define a string.*/
do while ctr<3 /*keep truckin' until finished.*/
do while ctr<3 /*keep truckin' until finished. */
call makeItem sep, string /*invoke the makeItem function.*/
call makeItem sep, $ /*invoke the makeItem function. */
end /*while*/
end /*while*/
return</lang>
return</lang>
{{out|output|text=&nbsp; when using the default input:}}
{{out|output|text=&nbsp; when using the default input:}}