This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Assignment 1 CIS 252 Intro to Computer Science Coverage This homework covers material through the first two chapters of Haskell: The Craft of Functional Programming (HCFP). Logistics This homework is officially due in class on Thursday, January 27 . However, it comes with an automatic extension: anything submitted to the bin in CST 3-210 by 1pm on Friday, January 28 will be accepted as being on time. You may work singly or in pairs on this assignment. What to turn in You should turn in a hard copy of your source code and a transcript demonstrating convincingly that your code is correct. You should also submit your code (but not the transcript) electronically . Look here for details on what the grader will be expecting (you can ignore the design recipe comment for this homework, since weve not yet discussed it in class). Exercises You may use any code from lecture that you wish: in fact, I encourage you to do so . However, you should include a note in your comments indicating that you are doing so and specifying which functions you are reusing. You will need to grab a copy of Pictures.hs to use the Pictures module. Do not add your code to this file. Instead, you should include an import Pictures directive at the top of your file. Please note: The solutions for these problems can all be written in a single line or two of Haskell, although possibly requiring the use of a simple helper function. If your code is significantly more complicated than that, you should stop, take a deep breath, and look for a simpler solution. 1. HCFP, Exercise 2.4 and Exercise 2.5 (page 30) First, introduce the folowing Haskell definition: twoHorse :: Picture twoHorse = sideBySide horse (invertColour horse) Now, define each of the pictures illustrated in Exercise 2.4 and Exercise 2.5, using only twoHorse and the functions defined in the Pictures module (i.e., do not define any additional helper functions). 2. Write a Haskell function checker3 :: Picture -> Picture -> Picture such that (checker3 pic1 pic2) returns a 3 3 checkerboard alternating between pic1 and pic2 . 3. Write a Haskell function Spring 2011 Assignment 1 CIS 252 Intro to Computer Science diag3 :: Picture -> Picture -> Picture such that (diag3 pic1 pic2) returns a 3 3 grid, with the main diagonal (upper left to lower right) containing pic1 and all other spaces containing pic2 ....
View Full Document
This note was uploaded on 02/19/2011 for the course CIS 325 taught by Professor Worden during the Spring '11 term at Syracuse.
- Spring '11
- Functional Programming