Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

We've seen lists of symbols and lists of numbers; you can of course have a list with elements of any given type...--including other structures like

HTML
<tt>

posn

HTML
</tt>

_posn_s. This exercise just uses ideas you've already learned, but in new contexts.

  1. Define the type of lists of
    HTML
    <tt>
    posn
    HTML
    </tt>
    list of _posn_s.
  2. Write the templates of lists of
    HTML
    <tt>
    posn
    HTML
    </tt>
    template for list of posn_s. (NB: There are two non-primitive types here, one inductive the other an inductive type and one that simply consists of a structure. So this writing a program that processes a list of positions may require two templates or one, depending on if you believe in structure templatesusing two templates; a template for lists of _posn_s and a template for processing _posn_s. If you need to use two templates, you _also need to write two functions, one to process a list of positions and one to process positions.)
  3. Write the function positive-quadrant? , which takes in a single posn and returns true only when its components are both positive.
  4. Develop count-positive-quadrant , which takes a list of
    HTML
    <tt>
    posn
    HTML
    </tt>
    _posn_s and returns a count of those in the upper-right quadrant.
  5. Develop filter-positive-quadrant , which takes a list of
    HTML
    <tt>
    posn
    HTML
    </tt>
    _posn_s and returns a list of those in the upper-right quadrant.

...

Here are two reasonable definitions for non-empty lists.

  • Solution: comp211-lab01.ss (https:wikiriceedudisplayCSWIKI211lab01comp211lab01ss)

!! Access Permissions

  • Set ALLOWTOPICCHANGE = Main.TeachersComp211Group