1. Dynamic Sequences
- Posted by Joseph Martin <jam at EXIS.NET> Apr 07, 1997
- 1004 views
I understand how you can add strings to the beginning or end of sequences, but how can you delete a value from a sequence? i.e. foo = {12, 13, 14, 15} after command foo = {12, 14, 15}. I know I could probably write a routine to copy the whole sequence except for the unwanted value, but is there an easier way to do this? ~~>Joseph Martin ~~>Personal: joe at cyber-wizard.com ~~>Web: jam.net at poboxes.com ~~>URL: http://users.exis.net/~jam/
2. Re: Dynamic Sequences
- Posted by Michael Bolin <michaeltom at GEOCITIES.COM> Apr 07, 1997
- 996 views
- Last edited Apr 08, 1997
> I understand how you can add strings to the beginning or end of > sequences, but how can you delete a value from a sequence? > i.e. foo = {12, 13, 14, 15} after command foo = {12, 14, 15}. I know > I could probably write a routine to copy the whole sequence except > for the unwanted value, but is there an easier way to do this? 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. Hope this helps. Michael Bolin
3. Re: Dynamic Sequences
- Posted by James Powell <Wizard at DJO.COM> Apr 08, 1997
- 1015 views
>> I understand how you can add strings to the beginning or end of >> sequences, but how can you delete a value from a sequence? >> i.e. foo = {12, 13, 14, 15} after command foo = {12, 14, 15}. I know >> I could probably write a routine to copy the whole sequence except >> for the unwanted value, but is there an easier way to do this? > >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. > >Hope this helps. > >Michael Bolin > Hey, thanks! I have been wondering about this also, and couldnt figure out how to do it. Obviously I need to print the docs (I hate exiting an editor, reading a doc, and reentering an editor). I know i can read them while using ed, but I'm used to QEdit. Anyway, I have sent my order for the Complete Edition, and am anxiously awaing its arrival.
4. Re: Dynamic Sequences
- Posted by Colin Taylor <71630.1776 at COMPUSERVE.COM> Apr 08, 1997
- 995 views
Michael Bolin wrote: >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. By the way, the same approach works for adding an element to the middle of a sequence. To add an element E to sequence S at position P: S = S[1..P-1] & E & S[P..length(S)] Colin Taylor 71630.1776 at compuserve.com
5. Re: Dynamic Sequences
- Posted by Michael Bolin <michaeltom at GEOCITIES.COM> Apr 08, 1997
- 1003 views
- Last edited Apr 09, 1997
> >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