Nested function: Difference between revisions

m
→‎{{header|REXX}}: added/changed whitespace and comments.
m (→‎using a class: added phix/class)
m (→‎{{header|REXX}}: added/changed whitespace and comments.)
Line 1,148:
This REXX version is modeled after the '''FreeBASIC''' example   (and it has the
same limitations).
<lang rexx>/*REXX program showsdemonstrates that functions can be nested (an outer and inner function). */
ctr=0 0 /*initialize the CTR REXX variable.*/
call makeList '. ' /*invoke MakeListmakeList with the separator.*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
makeItem: parse arg sep,text; ctr= ctr +1 1 /*bump the counter variable. */
say ctr || sep || word(string, ctr) /*display three thingys to the terminal*/
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
makeList: parse arg sep; string= 'first second third' /*get arguments; define a stringstrong.*/
do while ctr<3 /*keep truckin' until finished.*/
call makeItem sep, string /*invoke the makeItem function.*/
end /*while*/
return</lang>
{{out|output|text=&nbsp; when using the default input:}}
'''output'''
<pre>
1. first