Re: [tutorial] Basic Sequence Operations
- Posted by irv Jan 27, 2019
- 1289 views
? 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?"