0
试图在计划合并两个列表,并运行到#void错误与我的代码合并方案
(define x '(1 2 3 4 5 6 7 8 15 10))
(define z '(11 12 13))
(define merge
(lambda (list1 list2)
(cond [(null? list1) list2] ;if first list is empty return second list
[(null? list2) list1] ;if second list is empty return first list
[(if (< (car list1) (car list2))
(cons (car list1) (merge (cdr list1) list2)))] ;if 1st item in 1st list is less than 1st item in second list (cons 1st item from 1st list with merge call)
[(if (> (car list1) (car list2))
(cons (car list2) (merge (cdr list2) list1)))] ;if 1st item in 1st list is greater than 1st item in second list (cons 1st item in the 2nd list with merge call)
)))
输出在合并结束了无效
> (merge x z)
(1 2 3 4 5 6 7 8 . #<void>)
>
非常感谢! – Hunter