Need some Haskell help please

Associate
Joined
21 May 2003
Posts
1,008
hi. I'm trying to write a program (very simple) which takes the length of the sides of a triangle and tells you waht the triangle is (equilateral isosceles etc)l.

here's the code so far:
module Triangle where
import Char

triangle :: Int -> Int -> Int -> String
triangle a b c =
if sorting a b c /= a
then triangle b c a
else
if a == b && b == c
then "Equilateral"
else if a >= b + c
then "Impossible"
else if a == b || a == c || c == b
then "Isosceles"
else if a*a == b*b + c*c
then "Right Angled"
else if a /= b && a /= c && c /= b
then "Scalene" else "zero"

sorting :: Int -> Int -> Int -> Int
sorting a b c =
if a > b && a > b
then a
else b


Problem is, i need to implement the "read" function so the lengths can be inputted with quotes. the read will simply convert the string to numbers.

at the moment is works fine if you input the numbers without quotes. if anyone can help i'd appreciate it this is very simple stuff but i can't work it out.
 
Hey dude

You a University of Bristol Student?

I think you may have asked me for help on this program the other day in labs? :d

Then again the department has a lot of students

Good luck finding your answer :p sorry for the useless comment

Karl
 
yeah i'm a bristol student but i don't go to labs. 12 midnight was the deadline but i sstill haven't got it done.

can you help me out a bit? i still want to know how it's done.
 
Cool more Bristol CS students. Make sure your program says invalid if any of the inputs are 0. Also for the java program make sure you use System.err.println to print out invalid. I didn't do this and I lost a couple of marks for it.
 
Sorry, been working a lot lately. Subway on Whiteladies road :)

It has been a while since I did haskell. best bet would be to email Ian Holyer, he knows everything and is very helpful. Cheers.

Karl
 
Back
Top Bottom