Re: Dynamic Sequences

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

> >Yes, there IS an easy way to do this:
> >Suppose you have a sequence called S, and want to delete element N:
> >
> >S = S[1..N - 1] & S[N + 1..length(S)]
> >
> >You could also make a function called remove() or something to do
> >this.
>
> I was using something similar to this in a program I made (funny, can't
> remember), with a procedure to do it for me. I'd just like to point out that
> if you do make a procedure or function with this then make sure that "S" is
> neither equal to 1 or the length of the sequence, so you'll probably have to
> do a check first.

You must mean element "N", not "S" :)

No, this technique will work even with the first or the last element.
Euphoria allows a slice such as

S[1..0]     or      S[length(S)+1..length(S)]

These simply return an empty sequence {}, which has no effect on the
concatenation operator, so it still works anyway.

Regards,
                Michael Bolin

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

Search



Quick Links

User menu

Not signed in.

Misc Menu