Hamilton LaboratoriesHamilton C shell 2012User guideSamples

min.csh

Oregon Coast

min.csh
Previous | Next

#  Find the minimum numeric value out of a list.  If none of the elements
#  are numeric, return 0.

#  Copyright (c) 1996-2012 by Hamilton Laboratories.  All rights reserved.

proc min( values )
   local i, j
   @ j = 0
   if ($#values) then
      for i = 0 to $#values - 1 do
         if (isnumber(values[i])) then
            @ j = values[i]
            break
         end
      end
      for i = i + 1 to $#values - 1 do
         if (isnumber(values[i]) && values[i] < j) @ j = values[i]
      end
   end
   return j
end

min $argv

Previous | Next