Module: Smullyan::Birds

Defined in:
lib/smullyan.rb,
lib/smullyan/birds/why.rb,
lib/smullyan/birds/lark.rb,
lib/smullyan/birds/finch.rb,
lib/smullyan/birds/robin.rb,
lib/smullyan/birds/kestrel.rb,
lib/smullyan/birds/phoenix.rb,
lib/smullyan/birds/warbler.rb,
lib/smullyan/birds/bluebird.rb,
lib/smullyan/birds/cardinal.rb,
lib/smullyan/birds/identity.rb,
lib/smullyan/birds/starling.rb,
lib/smullyan/birds/mockingbird.rb

Overview

All combinators are now in separate files

Constant Summary collapse

Why =

The Why bird (Y combinator) - fixed-point combinator Why f = f (Why f)

lambda { |f|
  ->(x) { f.call(->(v) { x.call(x).call(v) }) }.call(
    ->(x) { f.call(->(v) { x.call(x).call(v) }) }
  )
}
Y =

Traditional combinator names

Why
Sage =

Y combinator (fixed-point)

Why
L_derived =

Derived implementation: L = C B M

C.call(B).call(M)
L_direct =

Direct implementation for comparison/efficiency

->(x) { ->(y) { x.call(y.call(y)) } }
Lark =

Default to derived implementation

L_derived
L =
Lark
Finch =

The Finch bird (F combinator) The finch applies its third argument to the first and second arguments in reverse order. Finch x y z = z y x

->(x) { ->(y) { ->(z) { z.call(y).call(x) } } }
F =

Traditional combinator name

Finch
R =

The Robin - rotates arguments Robin x y z = x z y

->(x) { -> (y) { -> (z) { y.(z).(x) }}}
Robin =
R
Kestrel =

The Kestrel - returns the first of two arguments Kestrel x y = x

->(x) { ->(_y) { x } }
K =

Traditional combinator name

Kestrel
Phoenix =

phoenix (or phi) applies takes 4 arguments in total it applies the fourth argument to the 2nd & 3rd, and then applies the results of those to the first phi xyzw = x(yw)(zw)

B.(B.(S)).(B)
Phoenix_direct =
->(x) { ->(y) { ->(z) { ->(w) { x.(y.(w)).(z.(w)) }}}}
Phi =
Phoenix
Φ =
Phoenix
W_derived =

Derived implementation: W = C S I

C.call(S).call(I)
W_direct =

Direct implementation for comparison/efficiency

->(x) { ->(y) { x.call(y).call(y) } }
Warbler =

Default to derived implementation

W_derived
W =
Warbler
B_derived =

Derived implementation: B = S (K S) K

S.call(K.call(S)).call(K)
B_direct =

Direct implementation for comparison/efficiency

->(x) { ->(y) { ->(z) { x.call(y.call(z)) } } }
Bluebird =

Default to derived implementation

B_derived
B =
Bluebird
C_derived =

Derived implementation: C = S (B B S) (K K)

S.call(B.call(B).call(S)).call(K.call(K))
C_direct =

Direct implementation for comparison/efficiency

->(x) { ->(y) { ->(z) { x.call(z).call(y) } } }
Cardinal =

Default to derived implementation

C_derived
C =
Cardinal
I_derived =

I is SKK

S.(K).(K)
I_direct =
->(x) { x }
Identity =

Traditional combinator names

I_derived
I =

I combinator

Identity
Idiot =

Alternative name from Smullyan's book

Identity
Starling =

The Starling - distributes its third argument to both its first and second Starling x y z = x z (y z)

->(x) { ->(y) { ->(z) { x.call(z).call(y.call(z)) } } }
S =

Traditional combinator name

Starling
M_derived =

Derived implementation: M = S I I

S.call(I).call(I)
M_direct =

Direct implementation for comparison/efficiency

->(x) { x.call(x) }
Mockingbird =

Default to derived implementation

M_derived
M =
Mockingbird