Re: [tutorial] Basic Sequence Operations

new topic     » goto parent     » topic index » view thread      » older message » newer message
irv said...
? insert(s,99,8) 
-- {1,2,3,99} 

Note that this, too is semantically puzzling. Any number larger than the length of the sequence just appends, resulting in a sequence of length 4. It doesn't expand the sequence to the required length, and then set s[8] = 99, as one might expect. But that would bring up another problem: what values are to be used to fill in s[4..7]?

The alternative would be to have errors - something like s[0] doesn't exist! and can't insert past end of sequence! Those would be easy to add.

The real question being "is this a problem worth fixing?"

The Phix version of insert) crashes "as expected."

This looks like a ?feature? of oE that no-one has noticed until now.

It looks like Python also has this strange kind of behavior.

I would describe the oE behaviour as a bug.

sequence s = {1,2,3} 
 
s = insert(s, 99, -11 ) 
? s 
--> {99,1,2,3} 

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu