smullyan 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c03c1b73d0e4b82d767b8edcff5cdd4b3746b8f25f0584095826c12aede049e
4
- data.tar.gz: 1e760c61bd407b69b4f283ecee9aa468c107964fef7d97d72734a8ec298e9ba3
3
+ metadata.gz: 9728ee75a0e8f7fd5ace7d83955a13ec06cea10ed8c03f76987642553c6cc2a2
4
+ data.tar.gz: f7c282378c225eb4e0095ab0d8e4966d8febd79ce8cd21768db71d7f0817eaa1
5
5
  SHA512:
6
- metadata.gz: f90e78e8f5bb3cdf6293fc09ec9062ae52a36992e656de9b66606e92a260bc7a8462e6d55fefb85e3e77192b73d6d8fa846645ce11fab1b849f8cb6e4234f2aa
7
- data.tar.gz: d59cc2c3de4d99b1216005319855bc926580bc3d50045a6a4e9983d543d8529b050515bdd83ee230ca2c7927440fb9182d4365dd3c4e5c3d5497a70665733e04
6
+ metadata.gz: c12f8528406b987b1fe958c20b69bc6cde1df16595c6fe970a5ffeb9e3efffa446091067259d7f43d41c591d8500a1111cfe29d4e7cd5bbc242343c0ec918915
7
+ data.tar.gz: 7ae541538c2145012b8e7dc1177e518fe7db0da38ab7411a928b4031a747bc1f2dce4d99431a1e3ff7c45b2d2033986bf95e7756959c53a8ebac94385329a77d
data/CLAUDE.md CHANGED
@@ -64,4 +64,4 @@ The gem implements combinators from combinatory logic, each with both a letter n
64
64
  - **M combinator (Mockingbird)**: `M x = x x` - self-application
65
65
  - **Y combinator (Why/Sage)**: Fixed-point combinator for recursion
66
66
 
67
- These are implemented as Ruby lambda functions in the `Smullyan::Birds` module, with both single-letter names (S, K, I, etc.) and bird names (Starling, Kestrel, Identity, etc.) available.
67
+ These are implemented as Ruby lambda functions in the `Smullyan::Birds` module, with both single-letter names (S, K, I, etc.) and bird names (Starling, Kestrel, Identity, etc.) available.
data/README.md CHANGED
@@ -34,30 +34,23 @@ starling = Smullyan::Birds::Starling # S combinator
34
34
  mockingbird = Smullyan::Birds::Mockingbird # M combinator
35
35
 
36
36
  # Example: Identity function derived from S and K
37
- identity = s.call(k).call(k)
38
- identity.call(42) # => 42
37
+ identity = s.(k).(k)
38
+ identity.(42) # => 42
39
39
 
40
40
  # Example: Function composition with the Bluebird
41
41
  bluebird = Smullyan::Birds::Bluebird
42
42
  double = ->(x) { x * 2 }
43
43
  increment = ->(x) { x + 1 }
44
- double_after_increment = bluebird.call(double).call(increment)
45
- double_after_increment.call(5) # => 12
44
+ double_after_increment = bluebird.(double).(increment)
45
+ double_after_increment.(5) # => 12
46
46
 
47
47
  # Example: Y combinator for recursion
48
48
  why = Smullyan::Birds::Why
49
- factorial = why.call(->(f) {
50
- ->(n) { n <= 1 ? 1 : n * f.call(n - 1) }
49
+ factorial = why.(->(f) {
50
+ ->(n) { n <= 1 ? 1 : n * f.(n - 1) }
51
51
  })
52
- factorial.call(5) # => 120
52
+ factorial.(5) # => 120
53
53
  ```
54
-
55
- ## Development
56
-
57
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
-
59
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
60
-
61
54
  ## Contributing
62
55
 
63
56
  Bug reports and pull requests are welcome on GitHub at https://github.com/philcrissman/smullyan.
@@ -14,7 +14,7 @@ module Smullyan
14
14
  # Direct implementation for comparison/efficiency
15
15
  B_direct = ->(x) { ->(y) { ->(z) { x.call(y.call(z)) } } }
16
16
 
17
- # Default to derived implementation for backward compatibility
17
+ # Default to derived implementation
18
18
  Bluebird = B_derived
19
19
  B = Bluebird
20
20
  end
@@ -15,7 +15,7 @@ module Smullyan
15
15
  # Direct implementation for comparison/efficiency
16
16
  C_direct = ->(x) { ->(y) { ->(z) { x.call(z).call(y) } } }
17
17
 
18
- # Default to derived implementation for backward compatibility
18
+ # Default to derived implementation
19
19
  Cardinal = C_derived
20
20
  C = Cardinal
21
21
  end
@@ -15,7 +15,7 @@ module Smullyan
15
15
  # Direct implementation for comparison/efficiency
16
16
  L_direct = ->(x) { ->(y) { x.call(y.call(y)) } }
17
17
 
18
- # Default to derived implementation for backward compatibility
18
+ # Default to derived implementation
19
19
  Lark = L_derived
20
20
  L = Lark
21
21
  end
@@ -14,7 +14,7 @@ module Smullyan
14
14
  # Direct implementation for comparison/efficiency
15
15
  M_direct = ->(x) { x.call(x) }
16
16
 
17
- # Default to derived implementation for backward compatibility
17
+ # Default to derived implementation
18
18
  Mockingbird = M_derived
19
19
  M = Mockingbird
20
20
  end
@@ -0,0 +1,16 @@
1
+ # # frozen_string_literal: true
2
+
3
+ module Smullyan
4
+ module Birds
5
+ # phoenix (or phi) applies takes 4 arguments in total
6
+ # it applies the fourth argument to the 2nd & 3rd, and then
7
+ # applies the results of those to the first
8
+ # phi xyzw = x(yw)(zw)
9
+ Phoenix = B.(B.(S)).(B)
10
+
11
+ Phoenix_direct = ->(x) { ->(y) { ->(z) { ->(w) { x.(y.(w)).(z.(w)) }}}}
12
+
13
+ Phi = Phoenix
14
+ Φ = Phoenix
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smullyan
4
+ module Birds
5
+ # The Robin - rotates arguments
6
+ # Robin x y z = x z y
7
+
8
+ R = ->(x) { -> (y) { -> (z) { y.(z).(x) }}}
9
+
10
+ Robin = R
11
+ end
12
+ end
@@ -15,7 +15,7 @@ module Smullyan
15
15
  # Direct implementation for comparison/efficiency
16
16
  W_direct = ->(x) { ->(y) { x.call(y).call(y) } }
17
17
 
18
- # Default to derived implementation for backward compatibility
18
+ # Default to derived implementation
19
19
  Warbler = W_derived
20
20
  W = Warbler
21
21
  end
@@ -4,7 +4,6 @@ module Smullyan
4
4
  module Birds
5
5
  # The Why bird (Y combinator) - fixed-point combinator
6
6
  # Why f = f (Why f)
7
- # Here's a practical implementation that works in applicative-order languages like Ruby
8
7
  Why = lambda { |f|
9
8
  ->(x) { f.call(->(v) { x.call(x).call(v) }) }.call(
10
9
  ->(x) { f.call(->(v) { x.call(x).call(v) }) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smullyan
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
data/lib/smullyan.rb CHANGED
@@ -12,6 +12,8 @@ require_relative 'smullyan/birds/mockingbird'
12
12
  require_relative 'smullyan/birds/why'
13
13
  require_relative 'smullyan/birds/lark'
14
14
  require_relative 'smullyan/birds/finch'
15
+ require_relative 'smullyan/birds/robin'
16
+ require_relative 'smullyan/birds/phoenix'
15
17
  require_relative 'smullyan/configurable_birds'
16
18
 
17
19
  module Smullyan
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smullyan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Crissman
@@ -87,6 +87,8 @@ files:
87
87
  - lib/smullyan/birds/kestrel.rb
88
88
  - lib/smullyan/birds/lark.rb
89
89
  - lib/smullyan/birds/mockingbird.rb
90
+ - lib/smullyan/birds/phoenix.rb
91
+ - lib/smullyan/birds/robin.rb
90
92
  - lib/smullyan/birds/starling.rb
91
93
  - lib/smullyan/birds/warbler.rb
92
94
  - lib/smullyan/birds/why.rb