RosettaCodeData/Task/Generator-Exponential/Phix/generator-exponential.phix

41 lines
792 B
Text
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
-- demo\rosetta\Generator_Exponential.exw
without js -- tasks
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
atom res
bool terminate = false
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
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
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
constant squares = task_create(powers,{2}),
cubes = task_create(powers,{3})
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
atom square, cube
task_schedule(cubes,1)
task_yield()
cube = res
sequence snq = {}
for i=1 to 30 do
do
task_schedule(squares,1)
task_yield()
square = res
while cube<square do
task_schedule(cubes,1)
task_yield()
cube = res
end while
until square!=cube
if i>20 then snq &= square end if
end for
?snq
terminate = 1
wait_key()