Jump to content

Nested function: Difference between revisions

m
Sidef comes before Simula
m (Sidef comes before Simula)
Line 1,375:
end func;</lang>
 
{{out}}
<pre>
1. first
2. second
3. third
</pre>
 
=={{header|Sidef}}==
<lang ruby>func make_list(separator = ') ') {
 
var count = 1
func make_item(item) {
[count++, separator, item].join
}
 
<first second third> «call« .map(make_item -> ).join("\n")
 
say make_list('. ')</lang>
{{out}}
<pre>
Line 1,446 ⟶ 1,465:
2. SECOND
3. THIRD
</pre>
=={{header|Sidef}}==
<lang ruby>func make_list(separator = ') ') {
 
var count = 1
func make_item(item) {
[count++, separator, item].join
}
 
<first second third> «call« make_item -> join("\n")
 
say make_list('. ')</lang>
{{out}}
<pre>
1. first
2. second
3. third
</pre>
 
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.