From 6e34508a02e0984b88b02b7549f6e7d628a02509 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 2 Apr 2006 16:09:55 +0000 Subject: [PATCH] merge -> merge-sorted-lists svn: r2576 --- collects/mzlib/list.ss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/collects/mzlib/list.ss b/collects/mzlib/list.ss index d5f0632a33..8f8c9d55d9 100644 --- a/collects/mzlib/list.ss +++ b/collects/mzlib/list.ss @@ -44,7 +44,7 @@ merge!) ;; used by sort-internal, but can be useful by itself - (define (merge! a b less?) + (define (merge-sorted-lists! a b less?) (define (loop r a b r-a?) ; r-a? for optimization -- is r connected to a? (if (less? (car b) (car a)) (begin (when r-a? (set-cdr! r b)) @@ -61,8 +61,8 @@ (if (null? (cdr a)) (set-cdr! a b) (loop a (cdr a) b #t)) a])) - ;; a non-destructive version for symmetry with merge! - (define (merge a b less?) + ;; a non-destructive version for symmetry with merge-sorted-lists! + (define (merge-sorted-lists a b less?) (cond [(null? a) b] [(null? b) a] [else (let loop ([x (car a)] [a (cdr a)] [y (car b)] [b (cdr b)]) @@ -88,7 +88,7 @@ (define (step n) (cond [(> n 3) (let* (; let* not really needed with mzscheme's l->r eval [j (quotient n 2)] [a (step j)] [b (step (- n j))]) - (merge! a b less?))] + (merge-sorted-lists! a b less?))] ;; the following two cases are just explicit treatment of sublists ;; of length 2 and 3, could remove both (and use the above case for ;; n>1) and it would still work, except a little slower