# http://snippets.dzone.com/posts/show/5119 class Array def map_with_index! each_with_index do |e, idx| self[idx] = yield(e, idx); end end def map_with_index(&block) dup.map_with_index!(&block) end end # TODO move this to cursor <-> use cursor for calculations class Array def between?(a,b) self.>= a and self.<= b end def <(other) (self.<=>other) == -1 end def <=(other) self.<(other) or self.==other end def >(other) (self.<=>other) == 1 end def >=(other) self.>(other) or self.==other end end