nodups - ;;template: ;;(define (remove-duplicate lon) ;;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "" "lang")((modname nodups) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; Helper functions: ; (define (check-match lon num) (cond [(empty? lon)false] [(= num (first lon))true] [else (check-match (rest lon) num)])) ;;remove-duplicates: (listof num) -> (listof num) ;; purpose: to only make a list with every number occuring once.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ;;template: ;;(define (remove-duplicate lon) ;; Example: ;;(remove-duplicates (cons 1 (cons 4 (cons 2 (cons 1 (cons 5 (cons 4 empty)))))))=> ;; (cons 1 (cons 4 (cons 2 (cons 5 empty)))) ; (define (remove-duplicates lon) (cond [(empty? lon) empty] [else (cond [(not(check-match (rest lon) (first lon))) (cons (first lon) (remove-duplicates (rest lon)))] [else (remove-duplicates (rest lon))])])) (remove-duplicates (cons 1 (cons 4 (cons 2 (cons 1 (cons 5 (cons 4 empty)))))))...
View Full Document

Ask a homework question - tutors are online