class Array

Public Instance Methods

arithmetic_progression?() click to toggle source
# File lib/mani_zanec_math/array/arithmetic_progression.rb, line 2
def arithmetic_progression?
  return true if size < 2
  (self.first..self.last).step((self.last-self.first)/(self.size-1)).to_a == self
end
foobar() click to toggle source
# File lib/mani_zanec_math/array/foobar.rb, line 2
def foobar
  arr = []
  self.each{|x|
    if (x.modulo(3) == 0 && x.modulo(5) == 0)
      arr.push("foobar")
    elsif (x.modulo(5) == 0)
      arr.push("bar")
    elsif (x.modulo(3) == 0 && x.modulo(2) != 0)
      arr.push("foo")
    else
     arr.push(nil)
    end
  }
  return arr
end