a3q3 - once. ;;Examples: (define (distinct-occurrence lst)...

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 "htdp-intermediate-lambda-reader.ss" "lang")((modname a3q3) (read-case- sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;;CS116 Assignment 3 Question 3 ;;r46wang 20319247 ;;distinct-occurrence: (listof any) -> (listof any) ;;consumes a list and returns a list with the same elements removed after appearing
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: once. ;;Examples: (define (distinct-occurrence lst) (cond [(empty? lst)empty] [else (cons (first lst) (distinct-occurrence (filter (lambda (x)(not(= (first lst) x))) lst)))])) ;;Tests: (check-expect (distinct-occurrence empty) empty) (check-expect (distinct-occurrence '(1 1 1 1)) '(1)) (check-expect (distinct-occurrence '(1 2 3 4)) '(1 2 3 4)) (check-expect (distinct-occurrence '(1 2 3 4 5 5 4 3 2 1)) '(1 2 3 4 5)) (check-expect (distinct-occurrence '(5 3 4 1 4 2)) '(5 3 4 1 2))...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 116 taught by Professor T.vasiga during the Fall '09 term at Waterloo.

Ask a homework question - tutors are online