對於Scheme編程語言來說,我是一個相當新的東西,我只是無法弄清楚這兩段代碼之間的區別,特別是我指出的那些代碼段。Scheme null?聲明
;program that returns the Nth element in a list where N is an integer argument
(define getElement
(lambda (N L)
(cond
((null? L) '())
((= N 1) (car L))
(#t(getElement (- N 1) (cdr L)));this line
)
)
)
;takes a list L and a number N and returns the list L but with the first N elements removed
(define remove
(lambda (N L)
(cond
((null? L) '())
((= N 0) L)
(#t(remove (- N 1) (cdr L)));and this line
)
)
)
爲什麼這些程序的輸出如此不同?除了檢查列表是否爲空以及整數N是否爲特定值之外,我無法看到條件語句對程序輸出後2行有什麼影響,請執行此操作。
這是我的第一篇文章,所以任何的建議是值得歡迎的