Add `Comparable#uniq`; CRuby2.4
MODIFY
mrbgems/mruby-enum-ext/mrblib/enum.rb
mrbgems/mruby-enum-ext/mrblib/enum.rb
@@ -708,4 +708,20 @@ module Enumerable
def nil.to_h
{}
end
+
+ def uniq(&block)
+ hash = {}
+ if block
+ self.each do|*v|
+ v = v.__svalue
+ hash[block.call(v)] ||= v
+ end
+ else
+ self.each do|*v|
+ v = v.__svalue
+ hash[v] ||= v
+ end
+ end
+ hash.values
+ end
end

MODIFY
mrbgems/mruby-enum-lazy/mrblib/lazy.rb
mrbgems/mruby-enum-lazy/mrblib/lazy.rb
@@ -158,6 +158,21 @@ class Enumerator
}
end
+ def uniq(&block)
+ hash = {}
+ Lazy.new(self){|yielder, val|
+ if block
+ v = block.call(val)
+ else
+ v = val
+ end
+ unless hash.include?(v)
+ yielder << val
+ hash[v] = val
+ end
+ }
+ end
+
alias force to_a
end
end

Add `Comparable#uniq`; CRuby2.4