functions 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/functions/prelude_lambda/basic.rb +3 -2
- data/lib/functions/prelude_lambda/math.rb +4 -2
- data/lib/functions/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c19b43b1fb45f2068817bd5ccc45d525e9e3cc090636d5a7e051ea5c5551fee
|
4
|
+
data.tar.gz: 70ee4229fd12a66ef92096710185585787790cbd705a3b4839c0e680de33e76d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 508cd5a0415d54bcd89a044f3d5c2c0c1a7ae62fe74cb9dc86eac710a3f176502dece0303f289dbc049d44fe6c90ebd9387ef0f7361b8e4f568ac8dbb1607f0c
|
7
|
+
data.tar.gz: 1ad7f73e57ca8dbbf01aaeb9df26c071c03fa62c23538eee00c41ccf352c84ae504b99e719ad30e289ba2728e22489fb7677f22949fd4dfdb329caf6913d13b5
|
@@ -41,7 +41,8 @@ module Functions
|
|
41
41
|
# manually curried version of the Compose function
|
42
42
|
ComposeCurried = ->(f) { ->(g) { ->(x) { f.(g.(x)) } } }
|
43
43
|
|
44
|
-
|
44
|
+
# reduce a list of functions right to left
|
45
|
+
Chain = ->(*fns) { fns.reduce { |f, g| ->(x) { f.(g.(x)) } } }
|
45
46
|
|
46
47
|
# composes two functions in reverse sequence
|
47
48
|
After = ->(f, g, x) {
|
@@ -100,7 +101,7 @@ module Functions
|
|
100
101
|
|
101
102
|
Filter = ->(f, xs) { xs.select { |x| f.(x) } }.curry
|
102
103
|
|
103
|
-
Parallel = ->(f, g, x) { [f.(x), g.(x)] }.curry
|
104
|
+
Pair = Parallel = ->(f, g, x) { [f.(x), g.(x)] }.curry
|
104
105
|
|
105
106
|
Par = ->(fs, x) { fs.map { |f| f.(x) } }.curry
|
106
107
|
|
@@ -2,6 +2,8 @@ module Functions
|
|
2
2
|
|
3
3
|
module Prelude
|
4
4
|
|
5
|
+
To_Float = Send.(:to_f)
|
6
|
+
|
5
7
|
Max = Send.(:max)
|
6
8
|
|
7
9
|
Min = Send.(:min)
|
@@ -12,7 +14,7 @@ module Functions
|
|
12
14
|
|
13
15
|
Divide = ->(arr) { arr.inject(:/) }
|
14
16
|
|
15
|
-
Average = Parallel.(Sum,Length) > Divide
|
17
|
+
Average = Parallel.(Sum,Length) > Map.( To_Float ) > Divide
|
16
18
|
|
17
19
|
Power = ->(p,x) { x**p }.curry
|
18
20
|
|
@@ -30,4 +32,4 @@ module Functions
|
|
30
32
|
|
31
33
|
end
|
32
34
|
|
33
|
-
end
|
35
|
+
end
|
data/lib/functions/version.rb
CHANGED