langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
7
Task/Ackermann-function/Perl-6/ackermann-function-1.pl6
Normal file
7
Task/Ackermann-function/Perl-6/ackermann-function-1.pl6
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
sub A(Int $m, Int $n) {
|
||||
|
||||
$m == 0 ?? $n + 1 !!
|
||||
$n == 0 ?? A($m - 1, 1 ) !!
|
||||
A($m - 1, A($m, $n - 1));
|
||||
|
||||
}
|
||||
3
Task/Ackermann-function/Perl-6/ackermann-function-2.pl6
Normal file
3
Task/Ackermann-function/Perl-6/ackermann-function-2.pl6
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
multi sub A(0, Int $n) { $n + 1 }
|
||||
multi sub A(Int $m, 0 ) { A($m - 1, 1) }
|
||||
multi sub A(Int $m, Int $n) { A($m - 1, A($m, $n - 1)) }
|
||||
9
Task/Ackermann-function/Perl-6/ackermann-function-3.pl6
Normal file
9
Task/Ackermann-function/Perl-6/ackermann-function-3.pl6
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
proto A(Int \𝑚, Int \𝑛) { (state @)[𝑚][𝑛] //= {*} }
|
||||
|
||||
multi A(0, Int \𝑛) { 𝑛 + 1 }
|
||||
multi A(1, Int \𝑛) { 𝑛 + 2 }
|
||||
multi A(2, Int \𝑛) { 3 + 2 * 𝑛 }
|
||||
multi A(3, Int \𝑛) { 5 + 8 * (2 ** 𝑛 - 1) }
|
||||
|
||||
multi A(Int \𝑚, 0 ) { A(𝑚 - 1, 1) }
|
||||
multi A(Int \𝑚, Int \𝑛) { A(𝑚 - 1, A(𝑚, 𝑛 - 1)) }
|
||||
2
Task/Ackermann-function/Perl-6/ackermann-function-4.pl6
Normal file
2
Task/Ackermann-function/Perl-6/ackermann-function-4.pl6
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
say A(4,1);
|
||||
say .chars, " digits starting with ", .substr(0,50), "..." given A(4,2);
|
||||
Loading…
Add table
Add a link
Reference in a new issue