Wright State University
Department of Computer Science and Engineering
CS 480/680 Comparative Languages

     Fall 2009                               Assignment  1                                   Prasad



Functional Programming : Recursive Definitions and Higher-Order Functions  (15 pts)   (Due:  Oct 12)

          
         This Scheme programming assignment requires defining functions on a directory-file system with the intention of illustrating the power of recursive definitions, (and optionally, higher-order functions such as map, filter, foldl (accumulate), and foldr (reduce) (reminiscent of Google's Map-Reduce architecture)). You need to read up (i)  compound data,  (ii) lists, and (iii) iterative refinements from How to Design Programs.   You should use DrScheme's Intermediate Student level or beyond if you need access to predefined higher-order functions.

    You are required to solve Exercises 16.3.1, 16.3.2, 16.3.3, and 16.3.4 in Chapter 16, Section 16.3 obtaining definitions for EG44, how-many, du-dir, and find? respectively. You must provide contract, purpose, definition and test cases, as exemplified by the Design Recipe. See also asg1.pptx.

CS680 Only: The CS680 students must also do the "Challenge" part of Exercise 16.3.4. Specifically, define function find as indicated that returns a list of file paths if there are multiple occurrences of a file name in a directory tree.


Sample "Well-documented" Definition

; HtDP book Exercise 5.1.2
;
Develop the function check-guess. It consumes two numbers, guess and target.
; Depending on how guess relates to target, the function produces one of the following three answers:
;'
TooSmall
, 'Perfect, or 'TooLarge.


; CONTRACT: check-guess : number   number -> { TooSmall, Perfect, TooLarge }
; PURPOSE:  check-guess takes two numbers - a guess and a target, and
;           returns a symbol TooSmall, Perfect or TooLarge
;           depending on whether target is more, equal or less than guess
; CODE:
(define (check-guess guess target)
             (cond [(> guess target) 'TooLarge ]
                   [(< guess target) 'TooSmall ]
                   [(= guess target) 'Perfect ]
             )
)
; TEST CASES and EXPECTED OUTCOMES
;(in general, focus on boundary conditions and coverage)
(check-expect (check-guess 3 5) 'TooSmall)
(check-expect (check-guess 5 5) 'Perfect)
(check-expect (check-guess 7 5) 'TooLarge)


What to hand in?    
     
        Turn-in your well-documented solution as a Scheme file
fileSys.scm  by running the following command on unixapps1.wright.edu

%/common/public/tkprasad/cs480/turnin-pa1  fileSys.scm


T. K. Prasad ( 09/15/2009 )