Sha256: 590f1c857c0c3a0a4788e94e294268948a3791f5c183beaefeea0d3fc9ef81e3

Contents?: true

Size: 529 Bytes

Versions: 9

Compression:

Stored size: 529 Bytes

Contents

module Math

  #
  def self.min(array, &block)
    if block_given?
      if min = array.find{ |i| i }
        min = yield(min)
        array.each do |i|
          j = yield(i)
          min = j if min > j
        end
        min
      end
    else
      array.min
    end
  end

  #
  def self.max(array, block)
    if block_given?
      if max = find{|i| i}
        max = yield(max)
        each{|i|
          j = yield(i)
          max = j if max < j
        }
        max
      end
    else
      array.max
    end
  end

end

Version data entries

9 entries across 8 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/standard/facets/math/min.rb
facets-3.1.0 lib/standard/facets/math/min.rb
facets-3.0.0 lib/standard/facets/math/min.rb
facets-2.9.3 lib/standard/facets/math/min.rb
facets-2.9.2 src/standard/facets/math/min.rb
facets-2.9.2 lib/standard/facets/math/min.rb
facets-2.9.1 lib/standard/facets/math/min.rb
facets-2.9.0 lib/more/facets/math/min.rb
facets-2.9.0.pre.2 lib/more/facets/math/min.rb