in reply to sorting a vec
When you say "sort a vec", do you mean something like: given an input bit sequence "01001010", the output sequence should be "00000111"?
If that's what you mean, and the homework assignment is to do this without using "sort", you could think of the problem as simply counting the number of set bits in the input vec, and setting that many low-order bits in the output vec.
To do this, you'd want the C-like '&' operator to test bits, the '|=' assignment operator to set bits, and the '<<' operator to position a given set bit. The "perlop" man page will explain their uses.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sorting a vec
by Anonymous Monk on Nov 02, 2003 at 15:53 UTC | |
by graff (Chancellor) on Nov 02, 2003 at 16:25 UTC | |
by Anonymous Monk on Nov 04, 2003 at 05:55 UTC |