new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
5
Task/Ackermann-function/Forth/ackermann-function-1.fth
Normal file
5
Task/Ackermann-function/Forth/ackermann-function-1.fth
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: acker ( m n -- u )
|
||||
over 0= IF nip 1+ EXIT THEN
|
||||
swap 1- swap ( m-1 n -- )
|
||||
dup 0= IF 1+ recurse EXIT THEN
|
||||
1- over 1+ swap recurse recurse ;
|
||||
14
Task/Ackermann-function/Forth/ackermann-function-2.fth
Normal file
14
Task/Ackermann-function/Forth/ackermann-function-2.fth
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
: ackermann ( m n -- u )
|
||||
over ( case statement)
|
||||
0 over = if drop nip 1+ else
|
||||
1 over = if drop nip 2 + else
|
||||
2 over = if drop nip 2* 3 + else
|
||||
3 over = if drop swap 5 + swap lshift 3 - else
|
||||
drop swap 1- swap dup
|
||||
if
|
||||
1- over 1+ swap recurse recurse exit
|
||||
else
|
||||
1+ recurse exit \ allow tail recursion
|
||||
then
|
||||
then then then then
|
||||
;
|
||||
Loading…
Add table
Add a link
Reference in a new issue