1. deleting from sequences
Gidday all...
I've been trying to delete an entire portion of a sequence from
existance, but im having a bit of trouble.
I have a sequence that contains a number, and an x any y co-ord like:
sequence = {{x},{y},{number}}
which soon truns into:
sequence = {{x},{y},{number}},{{x},{y},{number}},{{x},{y},{number}}...
etc.
What I want to be able to do is to delete, say, sequence[2] from
existance. Is this possible?
Cheers :)
Mike Fowler - mike.fowler at nelsun.gen.nz
o__ ---
_,>/'_ ---
(_) \(_) ---
Tip for the month: Buy a flatbed scanner - great mouse pads.
2. deleting from sequences
Hey to all!
Mike Fowler wrote:
>I have a sequence that contains a number, and an x any y co-ord like:
>sequence =3D {{x},{y},{number}}
>which soon truns into:
>sequence =3D {{x},{y},{number}},{{x},{y},{number}},{{x},{y},{number}}...=
>etc.
>What I want to be able to do is to delete, say, sequence[2] from
>existance. Is this possible?
>Cheers :)
Yes, it is possible. While there is no "delete" function, you can try th=
is
code to delete sequence[2]:
sequence =3D sequence[1] & sequence[3..length(sequence)]
Here's a delete procedure I wrote; it's easier than typing all that over
and over again:
------------------code starts here---------
procedure delete(sequence target, integer pos)
target =3D target[1..pos-1] & target[pos+1..length(target)]
end procedure
--usage:
sequence junk
junk =3D {15, "Hello World", '-', 2.3,"Euphoria",{15,45}}
delete(junk,2)
--now junk will equal:
--{15,'-',2.3,"Euphoria",{15,45}}
------------------code ends here----------
Just don't forget that if you delete an element from a sequence,
all the other elements will be shifted one over. That means that
some flags that you use could be messed up. Example:
constant MIDDLE =3D 3
sequence junk
junk =3D {1,54,34,26,65}
--now junk[MIDDLE] =3D 34, but if you do this:
delete(junk,2)
--now MIDDLE will still point to the 3rd element, =
--but that will be 26, not 34.
Hope this helps, Mike.
Regards,
Bryan Watts
3. deleting from sequences
Hey again!
I just realized I made quite a bone-headed mistake in my last post!
I wrote this code:
----
procedure delete(sequence target,integer pos)
target =3D target[1..pos-1] & target[pos+1..length(target)]
end procedure
I just realized that it will only change the local variable target!
The sequence you pass to it won't be affected. Here's the
new code (I'm still hitting myself in the head):
-----code starts here----
function delete(sequence target,integer pos)
target =3D target[1..pos-1] & target[pos+1..length(target)]
return target
end function
--usage
sequence junk
junk =3D {15,"Hello World",'-',2.3,"Euphoria",{15,45}}
junk =3D delete(junk,2)
--now junk =3D {15,'-',2.3,"Euphoria",{15,45}}
--------end code-------
Please excuse the mistake! I know we all get at least one in our
lives...
=
Regards,
Bryan Watts
4. deleting from sequences
-> Hey again!
-> I just realized I made quite a bone-headed mistake in my last post!
-> I wrote this code:
-> (I'm still hitting myself in the head):
<SNIP>
hey!... dont worrie... its just what i wanted. Thanks :)
-> Please excuse the mistake! I know we all get at least one in our
-> lives...
Absolute agreement!
Thanks again :)
Mike Fowler - mike.fowler at nelsun.gen.nz
o__ ---
_,>/'_ ---
(_) \(_) ---
Tip for the month: Buy a flatbed scanner - great mouse pads.