如何返回n
列表的第一个元素?这是我所拥有的:
(define returns(lambda (list n)
(cond ((null? list) '())
(((!= (0) n) (- n 1)) (car list) (cons (car list) (returns (cdr list) n)))
(else '()))))
例子:
(returns '(5 4 5 2 1) 2)
(5 4)
(returns '(5 4 5 2 1) 3)
(5 4 5)