CS 119 Lab 2Recursion

Objectives

  • Write linear and tail recursive functions
  • Perform the following tasks in the order given.

    1. Download the Lab2 project and import it into Eclipse as a Haskell project.
       
    2. Look at the function downUp.  We want this function to behave has follows:

      > downUp (word "cake")
      [cake ake ke e ke ake cake]

      > downUp (word "a")
      [a]


      If you try this however, you will notice that there is an error in the definition of downUp.

       

      Assignment:
      Fix the error in downUp.


       

    3. We want a function explode which behaves as follows:

      > explode (word "dynamite")

      [d y n a m i t e ]


      The function takes a word as its argument and returns a sentence containing the single letters of this word.
       

      Assignment:
      Write both linear recursive and tail recursive versions of the function explode.


       

    4. Now for more quilting...
       
      Assignment:
      Define a function stackCopies :: Int -> Image -> Image such that
      stackCopies n q will produce a stack of n copies of quilt q


       


    5.  
      Assignment:
      Define a function quilt :: Int -> Int -> Image -> Image in which
      quilt w h q will produce a quilt of width w and height h composed of multiple copies of quilt q.


       

    6. Feel free to design your own quilts.  I will display some of the best designs.
       
    7. Email your modified zipped project to me for grading.