diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-07-11 21:36:30 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-07-11 21:36:30 -0400 |
| commit | 997399661be0350e12d1b8eb4cad90ce56ed68f2 (patch) | |
| tree | 05be31959272d2b4ebf9eab6961a2ff523fd843a /fib.kpl | |
| parent | 78a31d8c270d13dfade672a3687f3c95d8bd19ae (diff) | |
remove non typed args
Diffstat (limited to 'fib.kpl')
| -rw-r--r-- | fib.kpl | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -1,31 +1,21 @@ /* Fibonacci sequence - n can be any numeric type */ -`export fib : ([n] - t : `type n - ? { - |(t = Int_signed; t = Float) { - ? n <= 0 { `return 0 } - } - t = Int_unsigned { - ? n = 0 { `return 0 } - } - { `panic "invalid type for n" } - } +`export fib : ([I64; I64.n] ? { + n = 0 { 0 } n < 2 { 1 } { `sync(fib; n - 1) + fib `sync n - 2 } } ) -`export fib_string : ([n] +`export fib_string : ([String; I64.n] "#MAGENTA#fib#(#CYAN#%#) #WHITE#=# #GREEN#%#\n" `format (n; fib `sync n) ) -`is_main ([] +`is_main ([Void] `use "sys" [args] ? 3 != `length args { `return `error String $ ( @@ -33,5 +23,5 @@ "#BOLD#WHITE#Usage: % % <n>#\n" `format (args `get 0; args `get 1) ) } - `value fib_string `sync U64 $ args `get -1 + `value fib_string `sync I64 $ args `get -1 ) |
