我被分配在Scheme中編寫合併排序,但我遇到了一些問題。我向教授展示了它,他說有一個簡單的錯誤。有人能幫我嗎? Plzz!計劃和合並排序?
(define msort
(lamdba(1st)
(cond
((null?? 1st) 1st)
((null? (cdr 1st)) 1st)
(#t ((letrec ((half (quotient (lenght 1st) 2))
(merge (lamdba (a b result)
(cond ((null? a) (apped (reserve a) result))
((null? b) (append (reserve a) result))
((> (car a) (car b) (merge a (cdr b) (cons (car b) result))
(#t (merge (cdr a) b (cons (car a) result)))))))
(merge (msort (take 1st half)) (msort (drop 1st half)) '()))))))
嘿約瑟夫,你是否改變了我的代碼?你能解釋你做了什麼嗎?我感謝您的幫助! – user3088420
它被認爲是不好的做法,以解決問題中的代碼,所以@jozefg可能只是格式化代碼,以便人類可讀。 – Sylwester
@Sylwester事實上,這有點不文明。對於OP:在每行上的代碼之前添加4個空格使您能夠語法高亮顯示+縮進 – jozefg