Last change
on this file since 8991 was
8991,
checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size:
1.1 KB

Rev  Line  

[8991]  1  ;* Mode: Lisp * 

 2  ;;;; Author: Paul Dietz 

 3  ;;;; Created: Thu Jul 17 06:42:27 2003 

 4  ;;;; Contains: Routines for testing SORT, NSORT 

 5  

 6  (inpackage :cltest) 

 7  

 8  (defun mynumericsort (list) 

 9  "Sort (nondestructively) a list of reals." 

 10  (if (null (cdr list)) 

 11  list 

 12  (let* ((len2 (ash (length list) 1)) 

 13  (l1 (mynumericsort (subseq list 0 len2))) 

 14  (l2 (mynumericsort (subseq list len2)))) 

 15  (mynumericmerge l1 l2)))) 

 16  

 17  (defun mynumericmerge (l1 l2) 

 18  (cond 

 19  ((null l1) l2) 

 20  ((null l2) l1) 

 21  ((<= (car l1) (car l2)) 

 22  (cons (car l1) (mynumericmerge (cdr l1) l2))) 

 23  (t 

 24  (cons (car l2) (mynumericmerge l1 (cdr l2)))))) 

 25  

 26  (defun generaterandomsorttest (n m) 

 27  (loop for i below n collect (random m))) 

 28  

 29  (defun randomsorttest (n m reps) 

 30  (loop 

 31  for i below reps 

 32  for list = (generaterandomsorttest (random n) m) 

 33  unless (equal (mynumericsort list) 

 34  (sort (copyseq list) #'<)) 

 35  collect list)) 

 36  

 37  (defun randomstablesorttest (n m reps) 

 38  (loop 

 39  for i below reps 

 40  for list = (generaterandomsorttest (random n) m) 

 41  unless (equal (mynumericsort list) 

 42  (stablesort (copyseq list) #'<)) 

 43  collect list)) 

Note: See
TracBrowser
for help on using the repository browser.