Skip to content

Instantly share code, notes, and snippets.

@klandergren
Created June 16, 2011 14:32
Show Gist options
  • Save klandergren/1029332 to your computer and use it in GitHub Desktop.
Save klandergren/1029332 to your computer and use it in GitHub Desktop.
SunnyCloud: 2.17 and 2.18
;; 2.17
(define (last-pair list)
(if (= (cdr list) ())
(car list)) ;; I think paren error on this line.
(cdr list)) ;; not calling last-pair recursively
;; 2.18 fails for me
(define (reverse list)
(= (cdr list) ()) ;; missing an if statement
(= new-list (cons (car list) ())
(cons (car list) (car new-list)))
;; Think of 2.18 in terms of 2.17: if you can find the last pair of a list
;; can't you call that recursively to build a new list last-element to first?
;; Testing
(reverse (list 1 4 9 16 25)) ;; => (list 25 26 9 4 1)
@gvinter
Copy link

gvinter commented Jun 16, 2011

Check out my fork..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment