Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create some sample data for the above types.
  2. Write the templates for the above types.
  3. Develop a function
    Code Block
    ; find? : symbol file -> boolean
    ; Returns whether the filename is anywhere in the
    ; tree of files represented by the file. This includes both
    ; simple file names and directory names.
    
    Note that this function is a vast simplification of{{find}}, the mother-of-all everything-but-the-kitchen-sink UNIX directory traversing command. If open a terminal window and enter
    Code Block
    man find
    
    to see what it can do.

    Use DrScheme's stepper to step through an example use of find?. Following the templates leads to an overall strategy known as depth-first search, i.e., it explores each tree branch to the end before moving on to the next branch.
  4. Develop the following function:
    Code Block
    ; any-duplicate-names? : file -> boolean
    ; Returns whether any (sub)directory directly or indirectly contains
    ; another directory or file of the same name. It does NOT check
    ; for duplicated names in separate branches of the tree.
    
    There is a straightforward way to write this function that just follows the template.
  5. Challenge: develop a program to check for duplicated names among all directories and files in the given tree, not just subdirectories.

    Here's a hint. Develop the following function:
    Code Block
    ; flatten-dir-once : symbol file -> (file or lof)
    ; Purpose: returns a structure like the original file, except that any (sub)directory with that name is removed and its contents are promoted up one level in the tree.
    
    Here are two pictorial examples, in both cases removing the directory
    namedtonamed to-remove. These illustrate why this function can
    return either a file or a list of files.

...

Follow the templates and think about a single
case at a time. If you do that, this exercise is not too difficult. If you don't follow the templates, you
are likely to run into difficulty.