This preview shows pages 1–2. 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: University of Arizona, Department of Computer Science CSc 372 Assignment 1 Due noon, Thu Sep 10 5% Christian Collberg September 3, 2009 1 Introduction The purpose of this assignment is to get started writing Haskell functions. For the purposes of this assign- ment, dont use any of the higher-order built-in functions such as map , foldr , etc. I want you to write all functions from scratch! You may use the ++-function for string concatenation. Hint: Its never wrong to introduce an auxiliary function when it makes the program easier to write or prettier to read! In fact, breaking up a larger function in two or more smaller ones is encouraged . Unless otherwise specified, you should use the guard syntax rather than the if-then-else syntax when you define recursive functions. 2 Simple Non-Recursive Functions 1. Define a function doublestring s which takes a string argument s and returns a new string consisting of two copies of s : [5 points] doublestring :: String -> String doublestring s = ... > doublestring "" "" > doublestring "hello" "hellohello" 2. Write a function charToString a which returns the one-character string consisting only of the char- acter a : [5 points] charToString Char -> String charToString c = ......
View Full Document
This note was uploaded on 10/05/2009 for the course C SC 372 taught by Professor Collberg during the Fall '08 term at University of Arizona- Tucson.
- Fall '08