Nested function: Difference between revisions

m
(→‎{{header|Lambdatalk}}: adding lambdatalk task)
Line 1,014:
 
=={{header|Lambdatalk}}==
Lambdatalk has neither closures nor states ...but outsidewe can do that, thanks to mutability of arrays behaving as "sandbox" of mutability.
<syntaxhighlight lang="scheme">
{def makeItem
{lambda {:c :item}
{div}{A.first {A.set! 0 {+ {A.first :c} 1} :c}}: :item}}
-> makeItem
 
{def makeList
 
{def makeItem
{lambda {:cs :a :itemi}
{div}{A.first {A.set! 0 {+ {A.first :ca} 1} :ca}}:s :itemi}}
 
{lambda {:s}
{S.map {{lambda {:cs :a :i} {makeItem :cs :i}} {A.new 0}}a :si}}}
:s {A.new 0}}
-> makeList
first second third
}}}
-> makeList
 
{makeList first second third.}
->
1:. first
2:. second
3:. third
</syntaxhighlight>
 
99

edits