returns the first n of list
问题 How to return the first n elements of a list? Here's what I have: (define returns(lambda (list n) (cond ((null? list) '()) (((!= (0) n) (- n 1)) (car list) (cons (car list) (returns (cdr list) n))) (else '())))) Examples: (returns '(5 4 5 2 1) 2) (5 4) (returns '(5 4 5 2 1) 3) (5 4 5) 回答1: You're asking for the take procedure: (define returns take) (returns '(5 4 5 2 1) 2) => (5 4) (returns '(5 4 5 2 1) 3) => (5 4 5) This looks like homework, so I guess you have to implement it from scratch.