lab419_core 0.0.6 → 0.0.7
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.
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Array
|
2
|
+
def without_indices *indices
|
3
|
+
s = size
|
4
|
+
indices = indices.map{ |x| x < 0 ? s + x : x }.uniq.reject{ |x| x >=s || x < 0 }.sort
|
5
|
+
return dup if indices.empty?
|
6
|
+
prefix =
|
7
|
+
indices.inject [[],0] do |(a, li), i|
|
8
|
+
[ a + (self[li, [i-li,0].max] || []), i.succ ]
|
9
|
+
end.first
|
10
|
+
|
11
|
+
prefix + ( self[indices.last.succ..-1] || [] )
|
12
|
+
end
|
13
|
+
end # class Array
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'lab419/core/enumerable/pair'
|
2
|
+
require 'lab419/core/array/without_indices'
|
3
|
+
module Enumerable
|
4
|
+
def each_pair options={}, &blk
|
5
|
+
if blk
|
6
|
+
return Lab419::Enumerable::Pair.pairs self, options, &blk
|
7
|
+
end
|
8
|
+
Enumerator.new do |y|
|
9
|
+
Lab419::Enumerable::Pair.pairs self, options do | pair |
|
10
|
+
y.yield pair
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def each_pair_with_rest options={}, &blk
|
16
|
+
if blk
|
17
|
+
return Lab419::Enumerable::Pair.pairs_with_rest self, options, &blk
|
18
|
+
end
|
19
|
+
Enumerator.new do |y|
|
20
|
+
Lab419::Enumerable::Pair.pairs_with_rest self, options do | pair_and_rest |
|
21
|
+
y.yield pair_and_rest
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end # module Enumerable
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'lab419/core/array'
|
2
|
+
module Lab419
|
3
|
+
module Enumerable
|
4
|
+
module Pair extend self
|
5
|
+
def pairs enum, options={}, &blk
|
6
|
+
enum.each_with_index do | e1, i1 |
|
7
|
+
enum.each_with_index do | e2, i2 |
|
8
|
+
next if i2 < i1 || i2 == i1 && !options[:reflexive]
|
9
|
+
blk.( [e1, e2 ] )
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
def pairs_with_rest enum, options={}, &blk
|
14
|
+
x = enum.to_a
|
15
|
+
enum.each_with_index do | e1, i1 |
|
16
|
+
enum.each_with_index do | e2, i2 |
|
17
|
+
next if i2 < i1 || i2 == i1 && !options[:reflexive]
|
18
|
+
blk.( [[e1, e2 ], x.without_indices(i1,i2)] )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end # module Pair extend self
|
23
|
+
end # module Enumerable
|
24
|
+
end # module Lab419
|
data/lib/lab419/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab419_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-debug19
|
@@ -99,17 +99,21 @@ extra_rdoc_files: []
|
|
99
99
|
files:
|
100
100
|
- lib/lab419/core/proc.rb
|
101
101
|
- lib/lab419/core/comparable.rb
|
102
|
+
- lib/lab419/core/enumerable.rb
|
102
103
|
- lib/lab419/core/memoization.rb
|
103
104
|
- lib/lab419/core/comparable/operators.rb
|
104
105
|
- lib/lab419/core/kernel.rb
|
105
106
|
- lib/lab419/core/extensions/composable_proc.rb
|
106
107
|
- lib/lab419/core/integer.rb
|
107
108
|
- lib/lab419/core/version.rb
|
109
|
+
- lib/lab419/core/array.rb
|
110
|
+
- lib/lab419/core/enumerable/pair.rb
|
108
111
|
- lib/lab419/core/object.rb
|
109
112
|
- lib/lab419/core/integer/operators.rb
|
110
113
|
- lib/lab419/core/integer/instance_methods.rb
|
111
114
|
- lib/lab419/core/hash.rb
|
112
115
|
- lib/lab419/core/array/flatten_once.rb
|
116
|
+
- lib/lab419/core/array/without_indices.rb
|
113
117
|
- lib/lab419/core/dir.rb
|
114
118
|
- LICENSE
|
115
119
|
- README.md
|
@@ -139,3 +143,4 @@ signing_key:
|
|
139
143
|
specification_version: 3
|
140
144
|
summary: Making Ruby's Core more powerfull and convinient
|
141
145
|
test_files: []
|
146
|
+
has_rdoc:
|