* Change `environment-link-name' to call `->environment' on its two
authorChris Hanson <org/chris-hanson/cph>
Sat, 12 Aug 1989 08:18:37 +0000 (08:18 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 12 Aug 1989 08:18:37 +0000 (08:18 +0000)
environment arguments.

* Move `vector-binary-search' to the global environment.  Fix a bug in
it -- a confusion between the < used for comparing integers, and that
for comparing keys.

* New variable `load/suppress-loading-message?' prevents the file
loader from printing the "loading -- done" messages.

* Implement `pathname-relative?' which accepts two pathnames; if the
second has a directory part which is a "prefix" of the first, this
returns a copy of the first pathname with the "prefix" removed.
Example:

    (pathname-relative? (->pathname "/usr/bin")
(->pathname "/usr/"))
   ==> #[pathname 5 "bin"]

v7/src/runtime/vector.scm

index b662c1c78c023f5b5246ab7e19d48a99e670b356..6054e71eae0dcbd677fd832b5da40f6155ebb1ee 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/vector.scm,v 14.4 1989/06/07 19:15:00 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/vector.scm,v 14.5 1989/08/12 08:18:37 cph Rel $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -127,6 +127,17 @@ MIT in each case. |#
 
 (define-integrable (vector-find-previous-element vector item)
   (subvector-find-previous-element vector 0 (vector-length vector) item))
+
+(define (vector-binary-search vector key<? unwrap-key key)
+  (let loop ((start 0) (end (vector-length vector)))
+    (and (< start end)
+        (let ((midpoint (quotient (+ start end) 2)))
+          (let ((item (vector-ref vector midpoint)))
+            (let ((key* (unwrap-key item)))
+              (cond ((key<? key key*) (loop start midpoint))
+                    ((key<? key* key) (loop (1+ midpoint) end))
+                    (else item))))))))
+
 (define-integrable (vector-first vector) (vector-ref vector 0))
 (define-integrable (vector-second vector) (vector-ref vector 1))
 (define-integrable (vector-third vector) (vector-ref vector 2))