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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d884db3d112ebd90fee4cf4ab66325b3800988821512fa097a5bd684dac6024b
4
- data.tar.gz: 640c89f3e47031e0f0320c8c9eb8ad811af88779658c6cb0befef25222aaecad
3
+ metadata.gz: 0c19b43b1fb45f2068817bd5ccc45d525e9e3cc090636d5a7e051ea5c5551fee
4
+ data.tar.gz: 70ee4229fd12a66ef92096710185585787790cbd705a3b4839c0e680de33e76d
5
5
  SHA512:
6
- metadata.gz: ed27fb9cface5baeb4dd000385eda0886425549ec90db99ea2f2afdde51b019cae3f479790d3d5107f48695feded0225e5fed7a50cd2196684df00bf9714a88a
7
- data.tar.gz: 5613d93811123dfbd9be92ff0e6c33101cb652af8ad8a4ca3afa4ec68c453ebd26317d5176bf09435f31d1b4d0b868a6d23b72d968aefc27c02c9ae10de63bdf
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
- Chain = ->(*fns) { fns.reduce { |f, g| lambda { |x| f.(g.(x)) } } }
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
@@ -1,3 +1,3 @@
1
1
  module Functions
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: functions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koen Handekyn