-2
我正在嘗試編寫一個函數,它會將一個新的數字添加到數字列表的末尾,但我似乎無法追查並糾正我的語法錯誤。有人能幫助我嗎?謝謝!我的程序怎麼沒有運行,我得到語法錯誤? (DrRacket/Scheme)
(define (add the-list element)
(cond
((empty? the-list) (list element)
(else (cons (first the-list) cons (add (rest the-list) element))))))
(check-expect (four (list 2 5 4) 1) (list 2 5 4 1)) ; four adds num at the end of lon
調用'檢查,期望'使用'add',而不是'four'。 – 2014-09-19 19:14:33