lab8 - #| = LAB 8 = | | Author(s): | Lab Section: | |# ;...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#| ====== LAB 8 ====== | | Author(s): | Lab Section: | |# ;;;; Utility Functions ; ;; Reloads the current file. (define (reload) (load "lab8.scm") ; Change file name if copied to a new file. ) ;; Square (define (square x) (* x x)) ( ;; REMINDER: ;; You must include test cases for all procedures you write. ;; No credit will be given without test cases showing working code. ;; ;; This lab does not give specific examples for testing the code. ;; Design test cases that will test many different situations. ;; For example, test for ordering (front, middle, and last elements in a list), ;; unexpected values (empty list), and bad numerical input. ;; ;; Be prepared to demonstrate that the code works as expected. ; ;;;; Test Case Values: ;;;; These are to help in testing by providing some examples. ;;;; You do not have to use them. ;;;; They may not be sufficient to test all the code you write. ; ;; Lists (define test-list1 '(1 2 3 4 5 6 7 8 9)) (define test-list2 '(5)) (define test-list3 '(1 2)) (define test-list4 '()) (define test-list5 '(1 2 3 4 5 6 7 8 9)) ( ;; Sequences (define test-seq1 '(1 2 3 4 5 6 7 8 . 9)) (define test-seq2 '(1 . 2)) (define test-seq3 '(7 8 . 9)) (define test-seq4 '()) ( (define test-even '(0 2 4 6 8 10)) (define test-odd '(1 3 5 7 9 11)) (define test-evens '(0 2 4 6 8 10)) (define test-odds '(1 3 5 7 9 11)) (define test-mixed '(0 2 1 3 4 6 5 7 8 10 9 11)) ( ;; Trees (define test-tree1 '(1 (2 3) 4))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
(define test-tree2 '((1 2 3 4))) (define test-tree3 '(1 ((2) 3) (4))) (define test-tree4 '((1 (2 (3 (4 (5))))))) (define test-tree5 '(((((1) 2) 3) 4) 5)) (define test-tree6 '((((1 2) 3 4) 5 6) 7 8)) ( ;;;; ;;;; Step 1 - Skipping Over Elements ;;;; (define ls (list 1 2 3 4 5)) ( (define empty-list ()) ( (define (get-last ls n) (if (>= n (length ls)) ls (get-last (cdr ls) n) ) ) ;; get-tail ; (define (get-tail ls index) (cond ((> index (length ls)) ()) ((< index 0) ()) (else (get-last ls (- (length ls) index)))
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2011 for the course CSCI 1901 taught by Professor Staff during the Fall '08 term at Minnesota.

Page1 / 7

lab8 - #| = LAB 8 = | | Author(s): | Lab Section: | |# ;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online