church 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module Church
2
+ COMPOSE = -> f, g { -> x { f[g[x]] } }
3
+ end
@@ -1,3 +1,3 @@
1
1
  module Church
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/lib/church.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'church/array'
2
2
  require 'church/hash'
3
3
  require 'church/io'
4
+ require 'church/lambda'
4
5
  require 'church/math'
5
6
  require 'church/utils'
6
7
  require 'church/version'
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ include Church
4
+
5
+ describe 'COMPOSE' do
6
+ ADD_TWO = -> x { 2 + x }
7
+ MUL_SIX = -> x { 6 * x }
8
+ SIX_X_PLUS_TWO = COMPOSE[ADD_TWO, MUL_SIX]
9
+
10
+ (-50..50).each do |x|
11
+ it "should compose two lambdas f and g and return f[g[x]]" do
12
+ expect(SIX_X_PLUS_TWO[x]).to be x * 6 + 2
13
+ end
14
+ end
15
+ 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.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -60,12 +60,14 @@ files:
60
60
  - lib/church/array.rb
61
61
  - lib/church/hash.rb
62
62
  - lib/church/io.rb
63
+ - lib/church/lambda.rb
63
64
  - lib/church/math.rb
64
65
  - lib/church/utils.rb
65
66
  - lib/church/version.rb
66
67
  - spec/array_spec.rb
67
68
  - spec/hash_spec.rb
68
69
  - spec/io_spec.rb
70
+ - spec/lambda_spec.rb
69
71
  - spec/math_spec.rb
70
72
  - spec/spec_helper.rb
71
73
  - spec/utils_spec.rb
@@ -99,6 +101,7 @@ test_files:
99
101
  - spec/array_spec.rb
100
102
  - spec/hash_spec.rb
101
103
  - spec/io_spec.rb
104
+ - spec/lambda_spec.rb
102
105
  - spec/math_spec.rb
103
106
  - spec/spec_helper.rb
104
107
  - spec/utils_spec.rb