Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: eb77573c45
Fetching contributors…

Cannot retrieve contributors at this time

file 29 lines (25 sloc) 0.72 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
(define (list-length lst)
    (if (null? lst)
        0
        (+ 1 (list-length (cdr lst)))))

(define (append lst1 lst2)
    (if (null? lst1)
        lst2
        (cons (car lst1) (append (cdr lst1) lst2))))

(define (list-reverse lst)
    (if (null? lst)
        '()
        (append (list-reverse (cdr lst)) (list (car lst)) )))

; Takes a list and returns a list of (cons elem elem) for each elem in the
; given list.
;
(define (pairify lst)
    (if (null? lst)
        '()
        (cons
            (cons (car lst) (car lst))
            (pairify (cdr lst)))))

(write (list-length (list 1 2 3 4 5)))
(write (append '(1 2 3 4) (list 9)))
(write (list-reverse (list 1 2 3 4 5)))
(write (pairify (list 1 2 3 4)))
Something went wrong with that request. Please try again.