|COMP1011 Exercises for Week 03|
|Computing 1A 05s2||
Tue 19 Jul 2005 14:37
When implementing the functions outlined below, make sure that you follow the Five Steps to Designing and Implementing a Function from the lecture.
Implement a function
sort2 :: Int -> Int -> (Int, Int)
that given two numbers returns a pair where the smaller of the two numbers is the first and the larger one the second component.
After an initial implementation without a
rewrite the definition to use a
where clause to avoid
the repeated statement of shared subcomputations.
type Colour = String type ColourPoint = (Int, Int, Colour)
changeColour :: ColourPoint -> Colour -> ColourPoint
that changes the colour of a colour point to the given value.
that checks if two color points have the same position.equalPos :: ColourPoint -> ColourPoint -> Bool
Why didn't we define
type Point = [Int]
in the lecture, but used a tuple instead?