On Jul 16, Konrad Foerstner said:

>Im looking for a method to exact the
>biggest element (number) out of array.
>Does anyone know a function for that?

Go through the array and stop when you've found the biggest number. ;)

No, honestly, you go through the array, and compare the current element
with the current maximum value.  If the current element is larger than the
current maximum, set the maximum equal to that value.

If you're dealing with negative numbers, you can't safely assign 0 to the
default maximum -- it's safest to set it equal to the first value in your
array.

Here is pseudo-code.  I trust you know enough Perl for the task:

  maximum = array[0]
  for E in array:
    if E > maximum: maximum = E

Of course, if you want super-speed, you can download the List::Util
module, and use its max() function.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to