Re: simple array manipulation without loops?



Why is Desired the desired ordering, and not Desired2 =
[1; 3; 9; 2; 4]?
Since 3 appears first in A, shouldn't it be before the
elements of B in the
Desired array?

Am I reading too much into "maintain the ordering"?


The output being [1; 9; 2; 3; 4] instead of [1; 3; 9; 2; 4]
is merely an artifact of the order the arguments are passed
to the "unique" function (ie for repeated values the last
occurance has it's indicie passed)

A = [1; 3; 9];
B = [2; 3; 4];
temp=[A; B];**
[r,m,n]=unique(temp);
Desired = temp(sort(m))
EQUALS[1; 9; 2; 3; 4]

Where as
A = [1; 3; 9];
B = [2; 3; 4];
temp=[B; A];**
[r,m,n]=unique(temp);
Desired = temp(sort(m))
EQUALS[2; 4; 1; 3; 9]

******

For my purpose, i must have at least one array maintain its
original order, however, i can achieve this by just making
that array the second argument in the stacking line temp=
[X,X].

.



Relevant Pages

  • Re: Really Stuck, Please Help
    ... I am not sure how to construct an array. ... Reading Master Log", of the "Copreco Master Log" workbook. ... Dim sourceBook As String ...
    (microsoft.public.excel.programming)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: Problem with a script
    ... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ...
    (comp.lang.php)
  • Re: Reading Files Byte-For-Byte
    ... >> attempting to read the file into an array. ... to be slower due simply to the additional commands required to accomplish ... I think the misunderstanding came about due to your mentioning reading the ... of printable characters, you'll need to do something else if your file data falls ...
    (microsoft.public.vb.general.discussion)
  • Re: Strange behavior when working with large files
    ... > The first time I read a file it will read into the array in about 2 ... The second time I try to read a file in it ... The file I'm reading here consists of 1.5 million lines (50MB all ... that Perl needs as more time as longer the lines are. ...
    (comp.lang.perl.misc)