From 471d24ce38c48fbad074419a38919235b6643e56 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Wed, 28 Aug 2019 21:22:06 +0300 Subject: [PATCH] Fix sort procedure in base system --- scheme-core/system.scm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scheme-core/system.scm b/scheme-core/system.scm index 9d7bb2c..75ce260 100644 --- a/scheme-core/system.scm +++ b/scheme-core/system.scm @@ -1092,14 +1092,16 @@ (simple-sort grtr)))))) (define (sort l (less? <) (key identity)) - (if (or (null? l) (null? (cdr l))) l - (let ((piv (car l))) - (receive (less grtr) - (separate (lambda (x) (less? (key x) (key piv))) - (cdr l)) - (nconc (sort less) - (list piv) - (sort grtr)))))) + (let sort ((l l)) + (if (or (null? l) (null? (cdr l))) + l + (let ((piv (car l))) + (receive (less grtr) + (separate (lambda (x) (less? (key x) (key piv))) + (cdr l)) + (nconc (sort less) + (list piv) + (sort grtr))))))) (define (apropos-list key) (let ((key (string-downcase