b-lazy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/b-lazy.rb +18 -1
- metadata +2 -2
data/lib/b-lazy.rb
CHANGED
@@ -36,6 +36,20 @@ module Enumerable
|
|
36
36
|
end
|
37
37
|
|
38
38
|
|
39
|
+
# This is similar to the tap method. It allows you
|
40
|
+
# to examine each item as it passes through the
|
41
|
+
# Enumeration pipeline. It is also handy if you want
|
42
|
+
# to modify an element's state as it passes through.
|
43
|
+
def touch(&blk)
|
44
|
+
Enumerator.new do |out|
|
45
|
+
self.each do |x|
|
46
|
+
blk.call x
|
47
|
+
out.yield x
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
39
53
|
def lselect(&blk)
|
40
54
|
Enumerator.new do |out|
|
41
55
|
self.each do |i|
|
@@ -164,7 +178,7 @@ module Enumerable
|
|
164
178
|
|
165
179
|
# The first time through, we will gradually collect all
|
166
180
|
# of self's enumerators into an Array.
|
167
|
-
|
181
|
+
s.lmap{|e| e.to_enum}.each do |e|
|
168
182
|
if e.has_next?
|
169
183
|
enums << e
|
170
184
|
out.yield e.next
|
@@ -188,5 +202,8 @@ module Enumerable
|
|
188
202
|
|
189
203
|
end
|
190
204
|
end
|
205
|
+
|
206
|
+
|
207
|
+
|
191
208
|
|
192
209
|
end
|