2.17

练习 2.17 请定义过程last-pair,它返回只包含给定(非空)表里最后一个元素的表:

(last-pair (list 23 72 149 34))
(34)

(define (last-pair lst)
  (if (null? lst)
      '()
      (if (null? (cdr lst))
          (car lst)
          (last-pair (cdr lst)))))

(last-pair (list 23 72 149 34))

results matching ""

    No results matching ""