RE: Standard Euphoria Library Project
- Posted by Al Getz <Xaxo at aol.com> Feb 07, 2001
- 416 views
Hi again Kat, I did notice a few problems with the function: function remove( integer i, sequence s ) -- remove ith element from s return s[1..i-1] & s[i+1..len] end function For example, passing the null sequence (s="") will cause an error. The possible error situations are 1. null sequence 2. i<=0 3. i>length of the sequence It seems a little range checking would be worthwhile: --improved 'remove()' function: function remove( integer i, sequence s ) -- remove ith element from s integer len len=length(s) if len>0 then --handles null sequence if i>0 then --handles i<=0 if i>len then --handles i greater then the length of the seq. return s else return s[1..i-1] & s[i+1..len] end if end if end if return "" end function This should take care of most problems associated with removing specific elements of a sequence. Good luck with it. --Al