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

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

I would like to add use of a leading 0 for octal notation as a trap. Maybe you have several values in a case statement with some three digit numbers and a couple of two digit numbers or a constant list declaration then you might be tempted to put a zero expressing numbers like 77 as 077. In Python 077 is not 77. Division is truncated if you start with integers: 1/2 = 0

>>> 077 
63 
>>> 1/2 
0 
>>>  

In EUPHORIA

? 077 
# 77 
? 1/2 
# 0.5 

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.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu