rubyplb 0.2.9 → 0.2.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +14 -0
- data/bin/rubyplb +1 -0
- data/lib/rubyplb.rb +3 -3
- data/lib/rubyplb/ary_with_combination.rb +33 -0
- data/lib/rubyplb/version.rb +1 -1
- metadata +4 -2
data/Gemfile.lock
ADDED
data/bin/rubyplb
CHANGED
data/lib/rubyplb.rb
CHANGED
@@ -9,9 +9,9 @@
|
|
9
9
|
require 'ruby_graphviz'
|
10
10
|
|
11
11
|
## load ary_with_combination if not Ruby 1.9.x
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
unless Array.instance_methods.index(:combination)
|
13
|
+
require 'ary_with_combination'
|
14
|
+
end
|
15
15
|
|
16
16
|
def showerror(sentence, severity)
|
17
17
|
if severity == 0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Array
|
2
|
+
@@combi_indices_hash = {}
|
3
|
+
|
4
|
+
def combi_indices(s,n)
|
5
|
+
ret = @@combi_indices_hash[s] ||= []
|
6
|
+
if ret.empty?
|
7
|
+
s.times{|i|
|
8
|
+
ret.dup.each{|a|
|
9
|
+
ret.push(a+[i])
|
10
|
+
}
|
11
|
+
ret.push([i])
|
12
|
+
}
|
13
|
+
end
|
14
|
+
ret.select{|a|a.size==n}
|
15
|
+
end
|
16
|
+
|
17
|
+
def combination(n)
|
18
|
+
# combination of Ruby 1.9.x returns array with a blank array as its top
|
19
|
+
combi_indices(self.size,n).collect{|a| self.values_at(*a)}.unshift([])
|
20
|
+
end
|
21
|
+
|
22
|
+
def subsets
|
23
|
+
(0..length).inject([]) do |ret, n|
|
24
|
+
ret.push(*combination(n))
|
25
|
+
end.uniq
|
26
|
+
end
|
27
|
+
|
28
|
+
def true_subsets
|
29
|
+
(1..length).inject([]) do |ret, n|
|
30
|
+
ret.push(*combination(n))
|
31
|
+
end.uniq
|
32
|
+
end
|
33
|
+
end
|
data/lib/rubyplb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyplb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.91
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-15 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Command line Pattern Lattice building tool written in Ruby.
|
16
16
|
email:
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- .document
|
24
24
|
- .gitignore
|
25
25
|
- Gemfile
|
26
|
+
- Gemfile.lock
|
26
27
|
- LICENSE
|
27
28
|
- README.md
|
28
29
|
- Rakefile
|
@@ -30,6 +31,7 @@ files:
|
|
30
31
|
- bin/rubyplb
|
31
32
|
- lib/ruby_graphviz.rb
|
32
33
|
- lib/rubyplb.rb
|
34
|
+
- lib/rubyplb/ary_with_combination.rb
|
33
35
|
- lib/rubyplb/version.rb
|
34
36
|
- lib/trollop.rb
|
35
37
|
- rubyplb.gemspec
|