From: Chris Hanson Date: Thu, 26 Jan 2017 22:57:37 +0000 (-0800) Subject: Implement fix:end-index and fix:start-index. X-Git-Tag: mit-scheme-pucked-9.2.12~227^2~80 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=221e8e942334bd1fedff21754984cb7a411b1946;p=mit-scheme.git Implement fix:end-index and fix:start-index. --- 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?