*In advance, I apologize my poor English!*
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.
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.
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.
(dividetwo '(1 2 3 4 5))
((1 2) (3 4) (5))
But my program work like this.
CL-USER> (dividetwo '(1 2 3 4 5))
((1 2) ((3 4) ((5))))
Below is my dividetwo program.
(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.