From ec6815345e25dad8ae188a915865c18657fea5f6 Mon Sep 17 00:00:00 2001 From: erana Date: Sat, 21 Jan 2012 00:52:58 +0900 Subject: [PATCH] xanadu - xml b-tree - 3 --- scsh/xanadu/b-tree.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scsh/xanadu/b-tree.scm b/scsh/xanadu/b-tree.scm index ec1e444..2af54f9 100644 --- a/scsh/xanadu/b-tree.scm +++ b/scsh/xanadu/b-tree.scm @@ -27,11 +27,14 @@ ;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (define (vector-median v) - (let ((retv (make-vector (inexact->exact (/ (vector-length v) 2))))) - (do ((i 0 (+ i 1))) - ((= i (/ (vector-length v) 2)) retv) - (vector-set! retv i (vector-ref v i)) - ))) + (let ((len (ceiling (/ (vector-length v) 2)))) + (let ((retl (make-vector len)) + (retr (make-vector len))) + (do ((i 0 (+ i 1))) + ((= i len) (list retl retr)) + (vector-set! retl i (vector-ref v i)) + (vector-set! retr i (vector-ref v (- len (+ i 1)))) + ))) (define (make-b-tree) (let ((*tree (make-vector 0)))