Nested function: Difference between revisions

Content added Content deleted
(Added PicoLisp)
(Task description: improve wording for inner function responsibility.)
Line 13: Line 13:
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 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.
The inner function (called <tt>MakeItem</tt> or equivalent) is reponsible for creating a list item. It accesses the separator from the outer function and modifies the counter.


'''References:'''
'''References:'''