smullyan 0.1.1 → 0.1.2
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 +4 -4
- data/CLAUDE.md +1 -1
- data/README.md +7 -14
- data/lib/smullyan/birds/bluebird.rb +1 -1
- data/lib/smullyan/birds/cardinal.rb +1 -1
- data/lib/smullyan/birds/lark.rb +1 -1
- data/lib/smullyan/birds/mockingbird.rb +1 -1
- data/lib/smullyan/birds/robin.rb +12 -0
- data/lib/smullyan/birds/warbler.rb +1 -1
- data/lib/smullyan/birds/why.rb +0 -1
- data/lib/smullyan/version.rb +1 -1
- data/lib/smullyan.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54c284e10e19e7e4904cf00787a48bd0b0263e36aa570c40140972612dec769e
|
|
4
|
+
data.tar.gz: '0275814586bb58cc526675df06aba5c16d088ef8f3b957e811885d6dba8d7bc8'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21dfbf121b9a84b114a39c875f5b08fd3a38d37c0b7976facce2782f81cc3bfd585d5028208eb714b46fdd38bdbf19a2f9396c189e64abba162a72235e7af000
|
|
7
|
+
data.tar.gz: 30b2c7fac3e4ea3f879bf4ed7781f9e58cb5f502df2409ac2bd2cd609ae89095b0319f31f4d23a474632febb115cf7b79e950ddcd7639300b9a54c16d47bc84a
|
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.
|
|
38
|
-
identity.
|
|
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.
|
|
45
|
-
double_after_increment.
|
|
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.
|
|
50
|
-
->(n) { n <= 1 ? 1 : n * f.
|
|
49
|
+
factorial = why.(->(f) {
|
|
50
|
+
->(n) { n <= 1 ? 1 : n * f.(n - 1) }
|
|
51
51
|
})
|
|
52
|
-
factorial.
|
|
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
|
|
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
|
|
18
|
+
# Default to derived implementation
|
|
19
19
|
Cardinal = C_derived
|
|
20
20
|
C = Cardinal
|
|
21
21
|
end
|
data/lib/smullyan/birds/lark.rb
CHANGED
|
@@ -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
|
|
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
|
|
17
|
+
# Default to derived implementation
|
|
18
18
|
Mockingbird = M_derived
|
|
19
19
|
M = Mockingbird
|
|
20
20
|
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
|
|
18
|
+
# Default to derived implementation
|
|
19
19
|
Warbler = W_derived
|
|
20
20
|
W = Warbler
|
|
21
21
|
end
|
data/lib/smullyan/birds/why.rb
CHANGED
|
@@ -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) }) }
|
data/lib/smullyan/version.rb
CHANGED
data/lib/smullyan.rb
CHANGED
|
@@ -12,6 +12,7 @@ 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'
|
|
15
16
|
require_relative 'smullyan/configurable_birds'
|
|
16
17
|
|
|
17
18
|
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.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Phil Crissman
|
|
@@ -87,6 +87,7 @@ 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/robin.rb
|
|
90
91
|
- lib/smullyan/birds/starling.rb
|
|
91
92
|
- lib/smullyan/birds/warbler.rb
|
|
92
93
|
- lib/smullyan/birds/why.rb
|