SICP Exercise 2.17-

2.18

(define (reverse items)
  (if (null? (cdr items))
      items
      (append  (reverse (cdr items)) (list(car items)))
      )
  )

(reverse (list 1 2 3 4))
 

2.17

(define (list-pair items)
  (if (null? (cdr items))
      items
      (list-pair (cdr items))
   )
  )
(list-pair (list 1 2 3 4))
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章