Nested function: Difference between revisions
Content added Content deleted
(→{{header|Lambdatalk}}: adding lambdatalk task) |
|||
Line 1,014: | Line 1,014: | ||
=={{header|Lambdatalk}}== |
=={{header|Lambdatalk}}== |
||
Lambdatalk has neither closures nor states |
Lambdatalk has neither closures nor states but we can do that, thanks to mutability of arrays behaving as "sandbox" of mutability. |
||
<syntaxhighlight lang="scheme"> |
<syntaxhighlight lang="scheme"> |
||
⚫ | |||
⚫ | |||
⚫ | |||
-> makeItem |
|||
{def makeList |
{def makeList |
||
⚫ | |||
⚫ | |||
⚫ | |||
{lambda {:s} |
{lambda {:s} |
||
{S.map {{lambda {: |
{S.map {{lambda {:s :a :i} {makeItem :s :a :i}} |
||
:s {A.new 0}} |
|||
⚫ | |||
first second third |
|||
}}} |
|||
⚫ | |||
{makeList |
{makeList .} |
||
-> |
-> |
||
1 |
1. first |
||
2 |
2. second |
||
3 |
3. third |
||
</syntaxhighlight> |
</syntaxhighlight> |
||