对于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行有什么影响,请执行此操作。
这是我的第一篇文章,所以任何的建议是值得欢迎的