Commit 213419ae authored by Juergen Nickelsen's avatar Juergen Nickelsen

028 passes (but generic sort currently very slow)

parent b2cc7ad1
......@@ -273,11 +273,13 @@
(apply #'string/= (cons n (cddr args)))
(apply #'string/= (cdr args))))))
(defun length (l)
"return the length of list l"
(if (null l)
(defun length (sequence)
"return the length of SEQUENCE"
(if (stringp sequence)
(setq sequence (split-string sequence "")))
(if (null sequence)
0
(1+ (length (cdr l)))))
(1+ (length (cdr sequence)))))
(defun list* (&rest args+)
"list of all args, with last arg as the cdr of the last pair constructed"
......@@ -339,7 +341,7 @@
(let* ((len (length l))
(first (div len 2))
(l1 (subseq l 0 first))
(l2 (subseq l (- len first)))
(l2 (subseq l first))
(merge (lambda (l1 l2)
(if (empty l1)
l2
......
......@@ -3,7 +3,10 @@
(testcmp "sort list 1" '(sort '(60) #'>) '(60))
(testcmp "sort list 2" '(sort '(60 94) #'>) '(94 60))
(testcmp "sort list 3" '(sort '(94 60) #'>) '(94 60))
(testcmp "sort list 4" '(sort '(66 43 42 68 6 15 9 30 51 81
(testcmp "sort list 4" '(sort '(94 60 23 24) #'>) '(94 60 24 23))
(testcmp "sort list 5" '(sort '(94 94 12 94) #'>) '(94 94 94 12))
(testcmp "sort list 6" '(sort '(94 12 94) #'>) '(94 94 12))
(testcmp "sort list 9" '(sort '(66 43 42 68 6 15 9 30 51 81
21 38 31 46 28 29 67 21 20 36) #'>)
'(81 68 67 66 51 46 43 42 38 36 31 30 29 28 21 21 20 15 9 6))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment