|
39. Ackermann’s Function ⍺ ack ⍵ ←→ f⍢(3∘+) ⍵ ⇒ (⍺+1)ack ⍵ ←→ f⍣(1+⍵)⍢(3∘+) 1 Ackermann’s function is defined on non-negative integers as follows:
ack←{
0=⍺: 1+⍵
0=⍵: (⍺-1) ∇ 1
(⍺-1) ∇ ⍺ ∇ ⍵-1
}
2 ack 3
9
3 ack 2
29
Lemma: If ⍺ ack ⍵ ←→ f⍢(3∘+) ⍵ ,
then (⍺+1)ack ⍵ ←→ Proof: By induction on ⍵ .
Using the lemma (or otherwise), it can be shown that:
0∘ack = 1∘+⍢(3∘+)
1∘ack = 2∘+⍢(3∘+)
2∘ack = 2∘×⍢(3∘+)
3∘ack = 2∘*⍢(3∘+)
4∘ack = */∘(⍴∘2)⍢(3∘+)
5∘ack = {*/∘(⍴∘2)⍣(1+⍵)⍢(3∘+) 1}
From http://xkcd.com/207
Appeared in J
[101,
109]
and in APL
[96].
|