Skip to content

Instantly share code, notes, and snippets.

@kidd
Created November 16, 2009 18:40
Show Gist options
  • Save kidd/236195 to your computer and use it in GitHub Desktop.
Save kidd/236195 to your computer and use it in GitHub Desktop.
(define (build-list n)
(cond ((= 1 n) (list n))
(else (append (build-list (- n 1)) (list n) ))))
(define (build-reverse a)
(cond ((= a 0) (list a))
(else (cons a (build-reverse (- a 1))))))
(define (my-reverse l)
(cond ((null? l) '())
(else (append (my-reverse (cdr l)) (list (car l))))))
(define (my-append l1 l2)
(if (null? l1) l2
(cons (car l1) (append (cdr l1) l2))))
(define (my-length l)
(if (null? l) 0
(+ 1 (my-length (cdr l)))))
(define (last-pair l)
(if (null? (cdr l)) (car l)
(last-pair (cdr l))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment