Hello!
On Wed, Mar 08, 2000 at 12:59:23PM +0100, Arne Bayer wrote:
> 1.)
> Does anybody know of (a set of) combinators describing the data flow
> through functions? The most prominent representative in this resepct
> is probably composition ('.' in Haskell).
Do you already know the SK(I) calculus?
S a b c = a c (b c)
K a b = a
I a = a
(I = S K K, because S K K a = K a (K a) = a = I a)
Every other combinations can be expressed with this calculus!
However, often some additional combinators are used, e.g. composition:
B a b c = a (b c)
However, you can of course express B from S, K and I (or omit I
using I = S K K):
B a b c = S (K a) b c
S (K a) = S (K S) K a
-> B a b c = S (K a) b c = S (K S) K a b c
-> B = S (K S) K
And there's C, which is called flip in Haskell:
C a b c = a c b
C = S (S (K S) (S (K K) S)) (K K)
as
S (S (K S) (S (K K) S)) (K K) a b c =
^
S (K S) (S (K K) S) a (K K a) b c =
^
S (K S) (S (K K) S) a K b c =
^
K S a (S (K K) S a) K b c =
^
S (S (K K) S a) K b c =
^
S (K K) S a b (K b) c =
^
K K a (S a) b (K b) c =
^
K (S a) b (K b) c =
^
S a (K b) c =
^
a c (K b c) =
^
a c b =
C a b c
[I'm not sure if I got the names of B and C right wrt "traditional"
usage, or if I swapped them]
> [...]
Regards, Hannah.