RE: Standard Euphoria Library Project

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

For some reason I thought reverse slicing would cause
a crash...

thanks, 
-Humberto
--- Irv Mullins <irvm at ellijay.com> wrote:
..
> You've somewhat underestimated Euphoria's abilities
> - all you really need is:
> sequence s
> 
> function remove(integer x, sequence s)
> if x < 1 or x > length(s) then return s
> end if
> return s[1..x-1]&s[x+1..length(s)]
> end function
> 
> s = "123"
> 
> for i = -1 to 5 do
>  printf(1, "Removing %d = %s\n", {i,remove(i,s)})
> end for
> 
> Example run:
> Removing -1 = 123
> Removing 0 = 123
> Removing 1 = 23
> Removing 2 = 13
> Removing 3 = 12
> Removing 4 = 123
> Removing 5 = 123 
> 
> Regards,
> Irv
> 
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu