Nested function: Difference between revisions

Wrote a proper task description
(Wrote a proper task description)
Line 1:
 
{{draft task}}
 
In many languages, functions can be nested, soresulting there arein outer functions and inner functions. The inner function can then access the variables offrom the outer function. In most languages, the inner function can also modify variables fromin the outer function.
 
'''The Task'''
See: [https://en.wikipedia.org/wiki/Nested_function Wikipedia: Nested function] article.
 
Write a program consisting of two nested functions that prints the following text.
 
The following examples for <tt>MakeList</tt> or <tt>makeList</tt> generate the following text:
 
1. first
2. second
3. third
 
The outer function (called <tt>MakeList</tt> or equivalent) is responsible for creating the list as a whole and is given the separator <tt>". "</tt> as argument. It also defines a counter variable to keep track of the item number. This demonstrates how the inner function can influence the variables in the outer function.
 
The inner function (called <tt>MakeItem</tt> or equivalent) is reponsible for creating one of the list items. It accesses the separator from the outer function and modifies the counter.
 
'''References:'''
 
:* [[wp:Nested_function]]
 
[[Category:Scope]]
 
=={{header|ALGOL 68}}==