All pastes #200580 Raw Edit

Anonymous

public text v1 · immutable
#200580 ·published 2006-10-13 07:51 UTC
rendered paste body
;; question 1

;; no-duplicates : number nlon -> boolean
(define (no-duplicates n lst)
  (cond [(empty? lst) true]
        [else (or (= (first lst) n) 
                  (no-duplicates n (rest lst)))]))

;; last : nlon -> number
;; obtain last item of list
(define (last lst)
  (cond [(empty? (rest lst)) (first lst)]
        [else (last (rest lst))]))

;; remove-duplicates : nlon -> nlon
(define (remove-duplicates lst)
  (cond [(empty? lst) empty]
        [(no-duplicates (last lst) lst) 
         (cons (first lst) (remove-duplicates (rest lst)))]))