RosettaCodeData/Task/Generator-Exponential/Phix/generator-exponential.phix
2017-09-25 22:28:19 +02:00

42 lines
854 B
Text

--
-- demo\rosetta\Generator_Exponential.exw
-- ======================================
--
bool terminate = false
atom res
procedure powers(integer p)
integer i=0
while not terminate do
res = power(i,p)
task_suspend(task_self())
task_yield()
i += 1
end while
end procedure
constant squares = task_create(routine_id("powers"),{2}),
cubes = task_create(routine_id("powers"),{3})
atom square, cube
task_schedule(cubes,1)
task_yield()
cube = res
for i=1 to 30 do
while 1 do
task_schedule(squares,1)
task_yield()
square = res
while cube<square do
task_schedule(cubes,1)
task_yield()
cube = res
end while
if square!=cube then exit end if
end while
if i>20 then
?square
end if
end for
terminate = 1