hwk3-haskellHomework 3: Programming in Haskell

How to Design Programs: An Introduction to Programming and Computing

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
WPI CS536 (F07) Homework 3 CS 536 Homework 3: Programming in Haskell Due: September 27, hardcopy in class and electronic via turnin (asgmt name hwk3 ) The Haskell Notes page provides pointers to haskell software downloads, tutorials, and a mapping from common Scheme functions to their Haskell equivalents. Problem 1: Prime Numbers 1. Write isPrime :: Integer -> Bool , which determines whether a given integer is prime. 2. Define primes :: [Integer] , the list of all primes. 3. Revise isPrime so that it only tests divisibility by prime factors. Just turn in the revised version. Problem 2: Longest Common Subsequence 1. Write buildList :: Int -> (Int -> a) -> [a] , where ((buildList n f) !! i) == (f i) (for all i in [0 . . n-1]). 2. Write buildTable :: Int -> Int -> (Int -> Int -> a) -> [[a]] , where (((buildTable n m f) !! i) !! j) == (f i j) (for all i in [0 . . n-1], j in [0 . . m- 1]). 3. Write lcs :: String -> String -> String , which computes the longest common subsequence of two strings s1 and s2. A good solution to this will exploit laziness. In particular, your submitted solution should not
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

hwk3-haskellHomework 3: Programming in Haskell - WPI CS536...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online