From: Stephen Adams Date: Wed, 4 Dec 1996 16:21:42 +0000 (+0000) Subject: Changed SORT to return a newly allocated list (as specified in the X-Git-Tag: 20090517-FFI~5315 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=5eef24173e4aadd317af7ff37540d90deba50a2d;p=mit-scheme.git Changed SORT to return a newly allocated list (as specified in the reference manual) in the case of a singleton list. --- diff --git a/v7/src/runtime/msort.scm b/v7/src/runtime/msort.scm index 1f0ed5fe7..4a7bde009 100644 --- a/v7/src/runtime/msort.scm +++ b/v7/src/runtime/msort.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: msort.scm,v 14.3 1996/12/01 17:23:03 adams Exp $ +$Id: msort.scm,v 14.4 1996/12/04 16:21:42 adams Exp $ Copyright (c) 1988-1996 Massachusetts Institute of Technology @@ -59,10 +59,14 @@ MIT in each case. |# (cons (car one) (merge (cdr one) two))))) - (cond ((or (pair? obj) (null? obj)) - (loop obj)) + (cond ((pair? obj) + (if (null? (cdr obj)) + (list (car obj)) ; must return newly allocated list + (loop obj))) ((vector? obj) (sort! (vector-copy obj) pred)) + ((null? obj) + '()) (else (error:wrong-type-argument obj "list or vector" 'SORT))))