in reply to Re: (nrd) finding highest number
in thread finding highest number

This may be Perlish, but it is also rather inefficient: O(n*log(n)) vs. O(n).

If you want to do it the Perlish way, why not use max that can be found in the wonderful List::Util module?

Just my 2 cents, -gjb-

Replies are listed 'Best First'.
•Re: Re: Re: (nrd) finding highest number
by merlyn (Sage) on Dec 05, 2002 at 16:05 UTC
    Oddly enough, it's more efficient to use sort rather than an explicit Perl loop for for up to a dozen or two elements, if I recall the benchmarks.

    Of course, List::Util has a max function, which would be faster still.

    But don't be so quick to optimize... you may be unoptimizing.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.