Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Nested-function/00-TASK.txt
Normal file
19
Task/Nested-function/00-TASK.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
In many languages, functions can be nested, resulting in outer functions and inner functions. The inner function can access variables from the outer function. In most languages, the inner function can also modify variables in the outer function.
|
||||
|
||||
|
||||
;Task:
|
||||
Write a program consisting of two nested functions that prints 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 responsible for creating a list item. It accesses the separator from the outer function and modifies the counter.
|
||||
|
||||
|
||||
;References:
|
||||
:* [[wp:Nested function|Nested function]]
|
||||
<br><br>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue