Sha256: a4014f0a548e17fa24acf08cb7e5e0509a4ce81fadd09f9d780e322bb90f1c83

Contents?: true

Size: 608 Bytes

Versions: 27

Compression:

Stored size: 608 Bytes

Contents

#require 'epitools/core_ext'
#require 'epitools/permutations'
require 'epitools'
require 'epitools/permutations'

describe "Permutations" do

  it "a*b" do
    ([1,2] * [3,4]).should == [ [1,3], [1,4], [2,3], [2,4] ]
  end

  it "a**2" do
    ([1,2] ** 2).should == [ [1,1], [1,2], [2,1], [2,2] ]
  end

  it "all_pairses" do
    [1,2,3,4].all_pairs.to_a.should == [
      [1,2],
      [1,3],
      [1,4],
      [2,3],
      [2,4],
      [3,4],
    ]

    # reflexive
    [1,2,3].all_pairs(true).to_a.should == [
      [1,1],
      [1,2],
      [1,3],
      [2,2],
      [2,3],
      [3,3],
    ]
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
epitools-0.5.136 spec/permutations_spec.rb
epitools-0.5.134 spec/permutations_spec.rb
epitools-0.5.133 spec/permutations_spec.rb
epitools-0.5.131 spec/permutations_spec.rb
epitools-0.5.130 spec/permutations_spec.rb
epitools-0.5.129 spec/permutations_spec.rb
epitools-0.5.128 spec/permutations_spec.rb
epitools-0.5.126 spec/permutations_spec.rb
epitools-0.5.125 spec/permutations_spec.rb
epitools-0.5.124 spec/permutations_spec.rb
epitools-0.5.123 spec/permutations_spec.rb
epitools-0.5.122 spec/permutations_spec.rb
epitools-0.5.121 spec/permutations_spec.rb
epitools-0.5.119 spec/permutations_spec.rb
epitools-0.5.118 spec/permutations_spec.rb
epitools-0.5.116 spec/permutations_spec.rb
epitools-0.5.115 spec/permutations_spec.rb
epitools-0.5.114 spec/permutations_spec.rb
epitools-0.5.113 spec/permutations_spec.rb
epitools-0.5.112 spec/permutations_spec.rb