functions 0.0.11 → 0.0.12

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
- N2JiMmVkMjY0ZDQ3NWNmYzE2MDhkNWIwNTQ2YzJkMTk1YWQ0ZmI3Yg==
4
+ N2Q2YWQzNDg3ZDc2MTRjMGZlNjhhOGUwYTM2MmYzMmEwZjBjN2JiMA==
5
5
  data.tar.gz: !binary |-
6
- YjQzNDMxOGZhYWY5YTRkNTYzMjk5YTNiOTcyNGZjMzY1Y2IxMmEzNg==
6
+ ZmYzMDBlZjM2NTZhNmE4MDBjOWRlYjMxNmY3MWViMjFlMjc0OTE0MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDZlZjkyMGM0OTkxZGJjZDVkZmNlYzI1MGJjZjJlMzUxMGEyMWU5MDgyMzU3
10
- YzlmMjlhNTU0ODZhNDVmYWY0NDA4NDE1N2E0OTYxODFkZGVlYWQxYzA0YjRl
11
- ZTlkZTljMDc1MjdhMTA0MDM5YzJmNzNhMDMxYzk5YzQxMGQ1Yzc=
9
+ ZGJkYWJmOTIxNzE2MGVmZDllMjU5ZDY3ZDZlYjc0YWM2NDI2YThkOTUzZGMw
10
+ ZDg1NjZiN2Q1MjI0NmY2OTNhMmI2Zjc1ODI2NWFhYmQzMjZjM2VjMTQxMzZk
11
+ M2VjNDFjNTYwZDlmYTBkNzVjZTU5MDhhN2ExZWUzZTcxN2YzNjY=
12
12
  data.tar.gz: !binary |-
13
- ZGUxNjhiZDE2YmU3NjBhNWYwYmM3MDZhNWJiNzE1MjJiNmNiYjI4OWM4MWM3
14
- YjYwM2Y1MTFkNTEwOTNkMmJlMmNhMDc3OGRhMzQzMDcxMTYzOTQwYTgzZmVj
15
- OTdmNThlZmU5ZDNlYTdhZmJiYmFjNTI5MTI4NTU4ZWM5ZDU4OTc=
13
+ NjEwOGRmMzc5ODRlODU3ZGE2ZGQ5NGRiMDE1ZWFhMGI2MTkwOGI5MDdjZTdl
14
+ NDhmOGJkNDJhOGU3NzRlZDA2ZDFjZGU4ZjFiN2M0OTdhZTA3NjBhZmUwMTUw
15
+ NzNlZDM1YzMzNDMwMGQxZDY5YzRkOTg1NTVjNTZkNjUxMWZiYmI=
@@ -81,9 +81,13 @@ 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
84
+ Merge_Hash = ->(as, bs) { as.merge(bs) { |k, a, b| [a, b] } }.curry
85
85
 
86
- Zip_Hash = ->(as, bs) { as.each_with_object({}) { |(k, a), h| h[k] = [a, bs[k]]; h } }.curry
86
+ Zip_Hash_Left = ->(as, bs) { as.each_with_object({}) { |(k, a), h| h[k] = [a, bs[k]]; h } }.curry
87
+
88
+ Zip_Hash_Inner = ->(as, bs) { as.each_with_object({}) { |(k, a), h| b = bs[k]; h[k] = [a, b] if b; h } }.curry
89
+
90
+ Zip_Hash_Right = ->(as, bs) { bs.each_with_object({}) { |(k, b), h| h[k] = [as[k], b]; h } }.curry
87
91
 
88
92
  Map = ->(f, a) { a.map { |x| f.(x) } }.curry
89
93
 
@@ -1,3 +1,3 @@
1
1
  module Functions
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -49,4 +49,13 @@ describe Functions::Prelude, "basic" do
49
49
  Merge_Sort.([3,3,5,6,7,1,2]).should == [1,2,3,3,5,6,7]
50
50
  end
51
51
 
52
+ it "merges hashes" do
53
+ a = { a: 'a', b: 'b' }
54
+ b = { a: '1', c: '3' }
55
+ Merge_Hash.(a,b).should == { a: ['a','1'], b: 'b', c: '3' }
56
+ Zip_Hash_Left.(a,b).should == { a: ['a','1'], b: ['b', nil] }
57
+ Zip_Hash_Right.(a,b).should == { a: ['a','1'], c: [nil, '3'] }
58
+ Zip_Hash_Inner.(a,b).should == { a: ['a','1'] }
59
+ end
60
+
52
61
  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.11
4
+ version: 0.0.12
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-18 00:00:00.000000000 Z
11
+ date: 2013-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: functional programming in ruby
14
14
  email: