church 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,4 +18,4 @@ EACH[[1, 2, 3], &-> e { p e } ]
18
18
 
19
19
  ### Why?
20
20
 
21
- The point of writing everything using Procs, for me at least, is to eventually transform programs into [non-alphanumeric](threeifbywhiskey.github.io/2014/03/05/non-alphanumeric-ruby-for-fun-and-not-much-else/) versions of themselves. Church's design goal is to make that an easier process.
21
+ The point of writing everything using Procs, for me at least, is to eventually transform programs into [non-alphanumeric](https://threeifbywhiskey.github.io/2014/03/05/non-alphanumeric-ruby-for-fun-and-not-much-else/) versions of themselves. Church's design goal is to make that an easier process.
data/lib/church/array.rb CHANGED
@@ -103,4 +103,11 @@ module Church
103
103
  coll[i] == elem ? i : i > SIZE[coll] ? nil : indexer[i + 1]
104
104
  })[0]
105
105
  }
106
+
107
+ # Returns the product of two arrays
108
+ PRODUCT = -> a, b {
109
+ REDUCE[MAP[[*0...SIZE[a]],
110
+ &-> x { MAP[[*0...SIZE[b]],
111
+ &-> y { [a[x], b[y]] }] }], &:+]
112
+ }
106
113
  end
data/lib/church/range.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Church
2
+ # Returns an array containing the numbers from start to finish, inclusive, incremented by step
2
3
  RANGE = -> start, finish, step = 1 {
3
4
  (ranger = -> ret {
4
5
  start >= finish ? ret : ranger[ret << start += step]
@@ -1,3 +1,3 @@
1
1
  module Church
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/spec/array_spec.rb CHANGED
@@ -122,3 +122,13 @@ describe 'INDEX' do
122
122
  expect(INDEX[[1, 2, 3], 4]).to be nil
123
123
  end
124
124
  end
125
+
126
+ describe 'PRODUCT' do
127
+ let(:a) { [1, 2, :potato] }
128
+ let(:b) { [3, 4] }
129
+
130
+ it "should return the product of two arrays" do
131
+ expect(PRODUCT[a, b]).to eq a.product b
132
+ expect(PRODUCT[b, a]).to eq b.product a
133
+ end
134
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: church
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: