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.

I would clarify that the limit isn't being modified, but that the limit is determined only once, at the beginning of the loop. If you need a dynamic condition, you need to use while or until.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu