shenanigans 1.0.17 → 1.0.18
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b77d114be718ddbf0ec79c50bfa217ef64049a2c4e8faeb7459f50d96e89571
|
4
|
+
data.tar.gz: 177ff03601eb1ed56c8d27321f434fe2f7d061893bfedb8006e9fe967dc73908
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa1a23f8c5e6c515037e89465902901cd119e76ad365fe249abe98e6a5ca4a9ec81b15f92835d20e2d2f9f345bbc5bf12f878b1cf76b9b694adba6a7b799d86
|
7
|
+
data.tar.gz: 930fd68a7e5230fc7d2c5a1b66db4f0c1fd22d8da68bd93fd1bb66b76290790fbbeeae3e8a7476e8a134ddeab39ff182fa674f04477a9fe300aba210ee9fbb3f
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class Array
|
2
|
-
# Similar to +reduce+/+inject+, but also returns intermediate values. Has the
|
3
|
-
# same interface as +reduce+/+inject+, so an initial value, an operator or
|
4
|
-
# both can be supplied. This method may eventually be moved to the
|
2
|
+
# Similar to +reduce+/+inject+, but also returns intermediate values. Has the
|
3
|
+
# same interface as +reduce+/+inject+, so an initial value, an operator or
|
4
|
+
# both can be supplied. This method may eventually be moved to the
|
5
5
|
# +Enumerable+ module.
|
6
6
|
#
|
7
7
|
# @example Symbol argument
|
8
8
|
# a = (1..4).to_a
|
9
|
-
# a.reductions(:+) #=> 10
|
9
|
+
# a.reductions(:+) #=> [1, 3, 6, 10]
|
10
10
|
# @example Initial value and symbol argument
|
11
|
-
# a.reductions(50, :+) #=> 60
|
11
|
+
# a.reductions(50, :+) #=> [50, 51, 53, 56, 60]
|
12
12
|
# @example Block argument
|
13
13
|
# %w(a b c).reductions { |s1, s2| s1+s2 } #=> ["a", "ab", "abc"]
|
14
14
|
def reductions(*args, &block)
|
data/lib/shenanigans/array.rb
CHANGED
@@ -4,7 +4,7 @@ module Kernel
|
|
4
4
|
#
|
5
5
|
# @example Composing symbols
|
6
6
|
# ["foo bar", "baz qux"].map(&fn(:split, :last)) #=> ["bar", "qux"]
|
7
|
-
# @example Composing
|
7
|
+
# @example Composing symbols and lambdas
|
8
8
|
# (1..3).map(&fn(:next, -> x { x * x }, -> x { x.to_f / 2 } ))
|
9
9
|
# #=> [2.0, 4.5, 8.0]
|
10
10
|
def fn(*funs)
|