functions 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTk3ZDc4OWUxMTEwY2QzODFiZjYzMGJjNTA2MDZjMjNhNWJiMDc5Mw==
4
+ ZjNiMzhiYWU2ZWZiMTFlMzY2MWFhZmI3ZDU1NWYzNmI4NDUxM2IxOA==
5
5
  data.tar.gz: !binary |-
6
- MWNiMjA0N2UzNmExNzg5NTAyZTcwYzUwOGEzODFhMDY0MGVjYjQwYg==
6
+ YjNiYTg3MTUxODAwYTIxNjZlNDJhMTkzZDFhYTM5YTY3NTU1MzdmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Nzc3N2VjMzBkM2NiNTVhOTQ3NWJlNzA3NjY4NGU3NWU0YWVlMzFmZDZmMDE5
10
- YjdkZWJlODZhYTEzZDYzMTdjNWY1YTE2NGRhM2U2MjM2Njk4MzUyMDU3YzBi
11
- NWIwNTJhMjUwNTI5ZWE0NGYyYzEyOWJmMTU0OWFiZjRmODc1MDA=
9
+ ZTljMTAwOTQzMGVhYTFhZmNhN2Q0ODQ3YTU2ZmVkNDNiMDNmZGQwMDBmMjUz
10
+ ZGQ0MDg0MWVjYzMxMmVkNDY5ZThlMzhjYzM5NmJjOWJjZTZmYWY5M2Y5ZmVh
11
+ Y2Y2ZmEwMWU3NjU0NjBmZTRhMDRiNjlkOTNlNzlkNDNmYzExNjc=
12
12
  data.tar.gz: !binary |-
13
- NzU5YzRiOWEzMmM5ZDVmMWQxZGY0OGZmNjU2NDBjMzVjMzFkMTBmNThjMzli
14
- MTRkMTYxYWMxMWFhMzZhN2UxZmFjODdmM2VjMjllOGQzY2NlMDU5NjViZTA2
15
- YmMzNjhjZDYxYTIzMGQ1YjcxMDM1MDVkNjBkODc1N2FiZWY4MDQ=
13
+ ZWJlZWQwZDUwZjgyMWEzYTNlNGU5NzFkNmQ2OTUwMGNmMmQyZmM4OTYyMDI0
14
+ NjdhNDczOGNmMTRmZmZlNTU2ZGZjMzIzZDIzZDI1MjMyOTU3MTE1YmEzZjI0
15
+ ZjU0NTQyY2NmNWUyMDk4NDBjZWE5NzE1ZDYwZTZlZGQ4ZjMxYTk=
@@ -81,6 +81,10 @@ module Functions
81
81
 
82
82
  Zip = ->(a, b) { a.zip(b) }.curry
83
83
 
84
+ Zip_Hash_Left = ->(as, bs) { as.merge(bs) { |k, a, b| [a, b] } }.curry
85
+
86
+ Zip_Hash = ->(as, bs) { as.each_with_object({}) { |(k, a), h| h[k] = [a, bs[k]]; h } }.curry
87
+
84
88
  Map = ->(f, a) { a.map { |x| f.(x) } }.curry
85
89
 
86
90
  Map_Hash = ->(f, h) { Hash[h.map{|k, v| [k, f.(v)] }] }.curry
@@ -93,9 +97,9 @@ module Functions
93
97
 
94
98
  Intersect = ->(as) { as.inject(:&) }
95
99
 
96
- Group = ->(f,a) { a.group_by(&f) }.curry # functional friend
100
+ Group = ->(f,a) { a.group_by(&f) }.curry
97
101
 
98
- Partition = ->(f) { Group.(f) > Send.(:values) } # functional friend
102
+ Partition = ->(f) { Group.(f) > Send.(:values) }
99
103
 
100
104
  FromTo = ->(from) { ->(to) { Range.new(from, to) } }
101
105
 
@@ -16,17 +16,17 @@ class Proc
16
16
  # Composition of Procs (functions): (f+g)(x) = f(g(x))
17
17
  def +(g)
18
18
  # Prelude::Compose.(self,g)
19
- ->(x) { self.(g.(x)) }
19
+ ->(*x) { self.(g.(*x)) }
20
20
  end
21
21
  # Composition of Procs (functions): (f<g)(x) = f(g(x))
22
22
  def <(g)
23
23
  # Prelude::Compose.(self,g)
24
- ->(x) { self.(g.(x)) }
24
+ ->(*x) { self.(g.(*x)) }
25
25
  end
26
26
  # Composition of Procs (functions): (f>g)(x) = g(f(x))
27
27
  def >(g)
28
28
  # Prelude::After.(self,g)
29
- ->(x) { g.(self.(x)) }
29
+ ->(*x) { g.(self.(*x)) }
30
30
  end
31
31
  # Partial evaluation of a Proc (function)
32
32
  def partial(a)
@@ -1,3 +1,3 @@
1
1
  module Functions
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: functions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koen Handekyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: functional programming in ruby
14
14
  email: