in reply to Array logic!

#! perl -slw use strict; my @numbers = qw[ 76.8 77.0 77.2 77.4 77.6 77.8 78.0 78.2 78.4 78.6 78.8 79.0 79.2 79.4 79.6 79.8 80.0 80.2 80.5 80.7 80.9 81.1 ]; my @small = qw[ 78.6 78.8 79.0 80.9 77.0 ]; my $i=0; $i++ until $numbers[ $i ] == $small[ 0 ]; @small = @numbers[ $i .. ( $i + $#small ) ]; print "@small"; __END__ P:\test>test 78.6 78.8 79.0 79.2 79.4

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

Replies are listed 'Best First'.
Re: Array logic!
by Abigail-II (Bishop) on Aug 06, 2003 at 12:36 UTC
    That can't be right. It assumes that the first element of @small is correct, but it was explicitely mentioned that the first element could be wrong.

    Abigail

      Reading between the lines of the post and attemptng to interprete the intent from the example given, I took the "even if first and last are incorrect" to mean the lowest and highest values in the small array.

      This was the only interpretation I could make fit the data supplied.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
      If I understand your problem, I can solve it! Of course, the same can be said for you.

        Very well, but that means your solution is wrong, as the lowest value in the small array happens to be $small [0].

        Eh, I can't read. In the example the lowest value isn't $small [0]. But what if it is?

        Abigail