summaryrefslogtreecommitdiff
path: root/ack.kpl
diff options
context:
space:
mode:
Diffstat (limited to 'ack.kpl')
-rw-r--r--ack.kpl16
1 files changed, 5 insertions, 11 deletions
diff --git a/ack.kpl b/ack.kpl
index 2161836..bba01ea 100644
--- a/ack.kpl
+++ b/ack.kpl
@@ -1,26 +1,20 @@
// Ackermann function
-`export ack : ([m; n]
- t : `type m;
- ? t != `type n {
- `panic "m and n must be the same type"
- }
- ? |(t = Int_signed; t = Float) {
- ? |(m < 0; n < 0) { `return 0 }
- }
+`export ack : ([I64; I64.m; I64.n]
? {
+ |(m < 0; n < 0) { 0 }
m = 0 { n + 1 }
&(m > 0; n = 0) { ack `sync (m - 1; 1) }
{ ack `sync (m - 1; ack `sync (m; n - 1)) }
}
)
-`export ack_string : ([m; n]
+`export ack_string : ([String; I64.m; I64.n]
"#MAGENTA#ack#(#CYAN#%#, #CYAN#%#) #WHITE#=# #GREEN#%#\n" `format (m; n; ack `sync (m; n))
)
-`is_main ([]
+`is_main ([Void]
`use "sys" [args]
? 4 != `length args {
`return `error String $ (
@@ -28,5 +22,5 @@
"#BOLD#WHITE#Usage: % % <m> <n>#\n" `format (args `get 0; args `get 1)
)
}
- `value ack_string `sync (U64 $ args `get -2; U64 $ args `get -1)
+ `value ack_string `sync (I64 $ args `get -2; I64 $ args `get -1)
)