Sha256: 8b753f0dc052cf71bc449d5a600300432207442f6073b9847c2b012b410c517d
Contents?: true
Size: 716 Bytes
Versions: 1
Compression:
Stored size: 716 Bytes
Contents
require 'nano/enumerable/commonality' module Enumerable # Like commonality but returns an array if no block is given. # def find_collisions( &blk ) #:yield: if block_given? commonality( &blk ) else commonality.values.flatten.uniq end end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCEnumerable < Test::Unit::TestCase def test_find_collisions a = [1,2,2,3,3,3] assert_equal( [2,3], a.find_collisions ) a = [1,2,2,3,3,3] r = {false=>[1, 2, 2], true=>[3, 3, 3]} assert_equal( r, a.find_collisions { |x| x > 2 } ) end end =end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-0.9.0 | lib/nano/enumerable/find_collisions.rb |