[PLT logo] TeachScheme! 2002

July/August, 2002

LAB for Wednesday afternoon




   PVD 2002: Our teachers benefitted HUGELY from a worksheet exercise
   on lists of structs (we didn't try this until Thursday, but
   recommend it for Wed afternoon lab).  Our worksheet set up a
   problem (lists of CD info: title, category, num-in-stock), then
   listed out all the steps with spaces for the answers (data defn for
   CDs, examples of CDs, data defn for list-of-CDs, examples of
   list-of-CDs, template for CDs, template for list-of-CDs).  We did
   not hand out the functions to be written until after each teacher
   finished the worksheet and had it checked by a TA.

   Functions to write:
  
    ;; total-stock : list-of-CD -> number
    ;; total number of CDs in stock (ie, sum numbers in stock per CD)

    ;; category-stock : symbol list-of-CD -> list-of-CD
    ;; produces list of all CDs from given list in named category
    
    ;; CHALLENGE -- unique-categories : list-of-CD -> list-of-sym
    ;; duplicate-free list of categories in list

    for non-challenge, update-stock to decrement number in stock of a
    certain CD.

   Handing out the sheets separately reinforced two ideas:
     - templates depend only on data
     - templates can be reused across many functions

   We recommend doing a problem like this for lab on Wed afternoon.



Generated on: Saturday, July 20th, 2002