[PLT logo] TeachScheme! 2002

July/August, 2002

Details for Wednesday morning


  

  Functions that produce lists:

    ;; convert-temps : list-of-number -> list-of-number
    ;; produces list of fahrenheit equivalents of celsius temps in given list

    This requires helper function F->C.

  The robo-rally game:

  A simple robot game has robots follow instructions like "walk 2,
  turn left, walk 4, walk 6, turn right ...".  We want a data
  definition to capture this.

  A list-of-num-and-sym is
    - empty, or
    - (cons number list-of-num-and-sym)
    - (cons symbol list-of-num-and-sym)

  Develop examples and template

    (cons 1 (cons 'left (cons 5 (cons 'right empty))))

  Show them the #| ... |# comment notations around templates

  Make sure they develop a cond with three clauses in cond, not 2 --
  this is a great example for reinforcing connection between templates
  and data definitions.

  ;; total-steps : list-of-num-and-sym -> number
  ;; produces the sum of all the numbers in the list

  [PVD 2002: This really worked their understanding of templates and
  the idea that data drives structure.  Worth the time]
   
  SORT: 
   given a list of numbers,
   produce a list of numbers with the exact same numbers, 
    but sorted in ascending order
   
  DON'T FORGET: compose functions/make up helpers!!!

  AUXILIARY PROGRAMS: 
   (1) cond expressions are in-line
   (2) auxiliary programs: if they encapsulate domain knowledge
   (3) auxiliary programs: if they are required -- process arb-large data
 
  PVD 2002: did sort as a class, derived contract/purpose for insert,
  then had them work on insert as a lead-in to lab.  At end of lab,
  talked about how got to insertion sort as opposed to other sorts.


[Point] LAB

Generated on: Saturday, July 20th, 2002