Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/fuzzy.rb
Instance Method Summary collapse
-
#non_decreasing ⇒ Object
Returns a new array by removing duplicate values in self.
- #uniq_values ⇒ Object
-
#uniq_values! ⇒ Object
Removes duplicate elements from self.
Instance Method Details
#non_decreasing ⇒ Object
Returns a new array by removing duplicate values in self. Duplicates by means of eql?.
44 45 46 47 48 49 |
# File 'lib/fuzzy.rb', line 44 def non_decreasing for i in 1..self.length-1 return false if self[i-1] > self[i] end return true end |
#uniq_values ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/fuzzy.rb', line 25 def uniq_values uniqArray = [] self.each { |e1| uniqArray << e1 unless uniqArray.find{ |o| o.eql?(e1) } } uniqArray end |
#uniq_values! ⇒ Object
Removes duplicate elements from self. Duplicates by means of eql?.
33 34 35 36 37 38 39 40 |
# File 'lib/fuzzy.rb', line 33 def uniq_values!() test = self.dup self.clear test.each { |e1| self << e1 unless self.find{ |o| o.eql?(e1) } } self end |