RE: Standard Euphoria Library Project
- Posted by Chris Bensler <bensler at mailops.com> Feb 07, 2001
- 417 views
David Cuny wrote: <SNIP> > function remove( integer i, sequence s) > -- remove ith element from s > return s[1..i-1] & s[i+1..length(s)] > end function <SNIP> What if the user tries to remove the first or last item? i would end up being 0 or greater than the length of the sequence.. Yeah you could say that it is up to the user to determine that, but if it's going to be in a StdLib, it should be fool proof and robust.. I use this.. function splice(sequence s, integer i) if i=1 then return s[2..length(s)] elsif i=length(s) then return s[1..i-1] else return s[1..i-1] & s[i+1..length(s)] end function any value passed to i will be handled.. if i is out of bounds, than EU will catch it.. This brings up a Q i have.. what is faster.. storing the length of the seqeunce, or just using length()? Chris