b-lazy 0.1.0 → 0.1.1
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/lib/b-lazy.rb +31 -7
- metadata +2 -2
data/lib/b-lazy.rb
CHANGED
@@ -285,13 +285,7 @@ module Enumerable
|
|
285
285
|
end
|
286
286
|
|
287
287
|
|
288
|
-
|
289
|
-
# all combinations of values from the provided Enumerators.
|
290
|
-
#
|
291
|
-
# Ex: [[1, 2], [3, 4]].lproduct.to_a -> [[1, 3], [1, 4], [2, 3], [2, 4]]
|
292
|
-
#def lproduct()
|
293
|
-
#
|
294
|
-
#end
|
288
|
+
|
295
289
|
|
296
290
|
|
297
291
|
# Repeats the same sequence of elements n times.
|
@@ -320,3 +314,33 @@ module Enumerable
|
|
320
314
|
end
|
321
315
|
|
322
316
|
end
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
class Integer
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
def self.positives
|
327
|
+
(1..Float::INFINITY).ensure_enum
|
328
|
+
end
|
329
|
+
|
330
|
+
def self.non_negatives
|
331
|
+
(0..Float::INFINITY).ensure_enum
|
332
|
+
end
|
333
|
+
|
334
|
+
def self.negatives
|
335
|
+
positives.lmap{|x| -1 * x}
|
336
|
+
end
|
337
|
+
|
338
|
+
def self.non_positives
|
339
|
+
non_negatives.lmap{|x| -1 * x}
|
340
|
+
end
|
341
|
+
|
342
|
+
def self.all
|
343
|
+
[[0], positives.lmap{|x| [x, -x]}.cons].cons
|
344
|
+
end
|
345
|
+
|
346
|
+
end
|