Array Questions [message #53423] |
Fri, 13 April 2007 09:19 |
Eric Hudson
Messages: 19 Registered: June 2006
|
Junior Member |
|
|
Hi,
I was wondering if anyone has any tricks for a couple of things I want
to do with arrays.
1) Remove columns & rows
I have a 2D (NxN) array and want to remove column i and row j. i,j
might be 0, they might be N-1, they might be anything in between. Is
there something simpler than handling these 3 different cases
separately and indexing [[ARR[*,0:j-1]],[ARR[*,j+1:N]]]...
2) Complements of sets
Often I end up with a set of element numbers and want to divide the
array into two pieces, those in the set and those not in the set.
Getting those in the set is trivial: ARR[set]. Is there a quick way
of generating the complement? It's nice that where() will give you
the complement, but I don't always get my sets from where.
3) "in set"
This isn't really isn't an array question, but I thought of it writing
the previous question. It's easy to use where to find elements of an
array that are equal to some value. Is there a quick way to find
elements that are in a set of values, something like:
where(Arr in set)
rather than looping through the set an unioning the results:
where(arr eq set[0]),where(arr eq set[1])....
This is often where my above question #2 arises, because although you
can easily union the wheres I'm not sure how to intersect the
complements.
Thanks in advance,
Eric
|
|
|