From c5f681d73d98c229b15eacd2791b376746d6f2a3 Mon Sep 17 00:00:00 2001 From: nodist Date: Thu, 21 May 2026 15:27:27 -0400 Subject: named signed and unsigned types --- ack.kpl | 6 +++--- fib.kpl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ack.kpl b/ack.kpl index bbd9784..44df478 100644 --- a/ack.kpl +++ b/ack.kpl @@ -3,10 +3,10 @@ `export ack : Fn[m; n] $ ( t : `type m; - ? |(t != `type n; t != Int[Any; Any; Any]) { - `panic "m and n must be the same type of Int" + ? |(t != `type n) { + `panic "m and n must be the same type" } - ? t = Int[Any; .signed; Any] { + ? |(t = Int_signed; t = Float) { ? |(m < 0; n < 0) { `return 0 } } ? { diff --git a/fib.kpl b/fib.kpl index cb6b5ef..8f003ee 100644 --- a/fib.kpl +++ b/fib.kpl @@ -1,19 +1,19 @@ /* Fibonacci sequence - n can be any signed or unsigned integer type + n can be any numeric type */ `export fib : Fn[n] $ ( t : `type n ? { - t = Int[Any; .signed; Any] { + |(t = Int_signed; t = Float) { ? n <= 0 { `return 0 } } - t = Int[Any; .unsigned; Any] { + t = Int_unsigned { ? n = 0 { `return 0 } } - { `panic "n must be a signed or unsigned Int" } + { `panic "invalid type for n" } } ? { n < 3 { 2 } -- cgit v1.2.3