Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Nested-function/Phix/nested-function-1.phix
Normal file
15
Task/Nested-function/Phix/nested-function-1.phix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function MakeList(string sep=". ")
|
||||
function MakeItem(integer env, string sep)
|
||||
integer counter = getd("counter",env)+1
|
||||
setd("counter",counter,env)
|
||||
return sprintf("%d%s%s",{counter,sep,{"first","second","third"}[counter]})
|
||||
end function
|
||||
integer counter = new_dict({{"counter",0}})
|
||||
sequence res = {}
|
||||
for i=1 to 3 do
|
||||
res = append(res,MakeItem(counter,sep))
|
||||
end for
|
||||
return res
|
||||
end function
|
||||
|
||||
?MakeList()
|
||||
17
Task/Nested-function/Phix/nested-function-2.phix
Normal file
17
Task/Nested-function/Phix/nested-function-2.phix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class counter
|
||||
public integer count
|
||||
end class
|
||||
function MakeList(string sep=". ")
|
||||
function MakeItem(counter c, string sep)
|
||||
c.count += 1
|
||||
return sprintf("%d%s%s",{c.count,sep,{"first","second","third"}[c.count]})
|
||||
end function
|
||||
counter c = new()
|
||||
sequence res = {}
|
||||
for i=1 to 3 do
|
||||
res = append(res,MakeItem(c,sep))
|
||||
end for
|
||||
return res
|
||||
end function
|
||||
|
||||
?MakeList()
|
||||
Loading…
Add table
Add a link
Reference in a new issue