Implement fix:end-index and fix:start-index.
authorChris Hanson <org/chris-hanson/cph>
Thu, 26 Jan 2017 22:57:37 +0000 (14:57 -0800)
committerChris Hanson <org/chris-hanson/cph>
Thu, 26 Jan 2017 22:57:37 +0000 (14:57 -0800)
src/runtime/fixart.scm
src/runtime/runtime.pkg

index fecafb7a989b36962b347628cfd45be8526b90c1..9d88f5a10f04947779eb0888648bb35bd9d5e050 100644 (file)
@@ -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)))
 \f
 ;;;; Flonums
 
index 6d4dd39bcc5098fb4f559c6b6c6880883f6dd43d..1d6a1f68e569b5731566211a8371ea9979a53c8b 100644 (file)
@@ -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?