From 221e8e942334bd1fedff21754984cb7a411b1946 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 26 Jan 2017 14:57:37 -0800 Subject: [PATCH] Implement fix:end-index and fix:start-index. --- src/runtime/fixart.scm | 18 ++++++++++++++++++ src/runtime/runtime.pkg | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/runtime/fixart.scm b/src/runtime/fixart.scm index fecafb7a9..9d88f5a10 100644 --- a/src/runtime/fixart.scm +++ b/src/runtime/fixart.scm @@ -142,6 +142,24 @@ USA. (fix:- value step) (cons value result)) result)))) + +(define (fix:end-index end length #!optional caller) + (if (default-object? end) + length + (begin + (guarantee index-fixnum? end caller) + (if (not (fix:<= end length)) + (error:bad-range-argument end caller)) + end))) + +(define (fix:start-index start end #!optional caller) + (if (default-object? start) + 0 + (begin + (guarantee index-fixnum? start caller) + (if (not (fix:<= start end)) + (error:bad-range-argument start caller)) + start))) ;;;; Flonums diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 6d4dd39bc..1d6a1f68e 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -211,6 +211,7 @@ USA. fix:and fix:andc fix:divide + fix:end-index fix:fixnum? fix:gcd fix:iota @@ -225,6 +226,7 @@ USA. fix:quotient fix:remainder fix:smallest-value + fix:start-index fix:xor fix:zero? fixnum? -- 2.25.1