epitools 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/epitools.gemspec +2 -2
- data/lib/epitools.rb +1 -0
- data/lib/epitools/basetypes.rb +14 -2
- data/spec/basetypes_spec.rb +4 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/epitools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epitools}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["epitron"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-07-19}
|
13
13
|
s.description = %q{Miscellaneous utility libraries to make my life easier.}
|
14
14
|
s.email = %q{chris@ill-logic.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/epitools.rb
CHANGED
data/lib/epitools/basetypes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'pp'
|
2
2
|
|
3
|
-
#
|
4
|
-
Enum
|
3
|
+
# Alias "Enumerable::Enumerator" to "Enum"
|
4
|
+
Object.const_set(:Enum, Enumerable::Enumerator) rescue nil
|
5
5
|
|
6
6
|
class Object
|
7
7
|
# Default "integer?" behaviour.
|
@@ -257,6 +257,18 @@ module Enumerable
|
|
257
257
|
result
|
258
258
|
end
|
259
259
|
|
260
|
+
#
|
261
|
+
# Returns the powerset of the Enumerable
|
262
|
+
#
|
263
|
+
# Example:
|
264
|
+
# [1,2].powerset #=> [[], [1], [2], [1, 2]]
|
265
|
+
#
|
266
|
+
def powerset
|
267
|
+
# the bit pattern of the numbers from 0..2^(elements)-1 can be used to select the elements of the set...
|
268
|
+
(0...2**size).map do |bitmask|
|
269
|
+
select.with_index{ |e, i| bitmask[i] == 1 }
|
270
|
+
end
|
271
|
+
end
|
260
272
|
|
261
273
|
end
|
262
274
|
|
data/spec/basetypes_spec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- epitron
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-19 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|