[Haskell-cafe] HELP
Yaadallah Khan
yk232 at hotmail.com
Thu Oct 21 18:11:57 EDT 2010
I am Studying for an exam, and i have just come accross the following 3 questions, i am not familiar with the functions, therefore i would appreciate any help.
!! i have already created painting 2 & 3 all i need is the 3 functions, for the three different tasks as shown below. the functions are the showPic, sizeRaw and isPic.
questions are:
1) – Define showPic :: Canvas -> IO () for displaying pictures on theterminal. Examples:
Cw2010> showPic (painting 2)+---+---+---+---+---+| a | n | e | x | a |+---+---+---+---+---+| m | p | l | e | t |+---+---+---+---+---+| e | x | t | i | s |+---+---+---+---+---+| s | h | o | w | n |+---+---+---+---+---+
Cw2010> showPic (painting 3)+---+---+---+---+---+---+---+| A | n | o | t | h | e | r |+---+---+---+---+---+---+---+| | t | e | s | t | ! | |+---+---+---+---+---+---+---+
2) – Furthermore, define sizeRaw :: Canvas -> (Int, Int) for findingout the size of a raw picture as demonstrated here.Cw2010> sizeRaw ["anexa","mplet","extis","shown"](5,4)
3) – Finally, define isPic :: Canvas -> Bool for checking a particularnecessary condition which items of type Canvas must satisfy (full orraw). The condition you should check for is whether all the ‘rows’ ofthe input have the same length. (It may be assumed that the inputof isPic is of type Canvas.) Examples:
Cw2010> isPic (painting 3)TrueCw2010> isPic (painting 4)False
Suggestion. I found it useful in my implementation to define and usehere the auxiliary function isEqual :: [Int] -> Bool; example:
Cw2008> isEqual [8,8,8,8]TrueCw2008> isEqual [8,8,4,8]FalseYou may wish to define and use isEqual in your implementation ofisPic too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101021/0e3fa2b4/attachment.html
More information about the Haskell-Cafe
mailing list