Hello!
I'm making "merge sort" program. I've been making a program that merges two lists.
And,I'll use embeded sort program as sort process in mergesort.
I have problem in first step of mergesort algorithm.
Correct program will divide list like this.
Code: Select all
(dividetwo '(1 2 3 4 5))
((1 2) (3 4) (5))
Code: Select all
CL-USER> (dividetwo '(1 2 3 4 5))
((1 2) ((3 4) ((5))))
Code: Select all
(defun divideTwo (list)
"this function (will) divide list into lists of list that contains two argument"
(defun divideTwo-iter (list)
(cond ((null (cdr list)) list)
((null (cddr list)) list)
(t (values (list (car list) (cadr list)) (divideTwo (cddr list))))))
(multiple-value-list (divideTwo-iter list))
I don't know why this program doesn't work.
Please tell me the way to modify this program or more better way to divide list into list of lists.