nodups - ; The first three lines of this file were inserted...

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-beginner-reader.ss" "lang")((modname nodups) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;;Ru Wang 20319247 r46wang ; ;;Assignment 4 ;;Question 3 ;;********************************************************************************* ********** * ;; Helper functions: ; ;;occurred: num (listof num) (listof num) -> boolean ;; On the condition that olon includes lon. ;;Purpose: determines if the number has been occurred previously in the list ;;Examples: (occurred 6 (cons 5 (cons 6 (cons 3 empty))) (cons 3 empty)) => true ;; (occurred 6 (cons 5 (cons 4 (cons 6 empty))) (cons 6 empty)) => false ;;Definition: (define (occurred num olon lon) (cond [(equal? olon lon) false] [else (cond [(= num (first olon)) true] [else (occurred num (rest olon) lon)])]))
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/21/2010 for the course CS 135 taught by Professor Vasiga during the Fall '07 term at Waterloo.

Ask a homework question - tutors are online