Re: Python has Traps; Does Euphoria have Programming Traps?

new topic     » goto parent     » topic index » view thread      » older message » newer message
SDPringle said...

One trap in EUPHORIA is if you modify the limit of a for loop while its running.

sequence set = {1,2,3,4,5,6,7,8} 
for i = 1 to length(set) do 
  if remainder(set[i],2)=0 then 
     set = set[1..i-1] & set[i+1..$] 
  end if 
end for 

This loop crashes.

FYI the above code works fine if you change the loop to

for i = length(set) to 1 by -1 do 

That particular idiom ("processing lists backwards") is quite common in my code.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu