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.
 
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.
 
Back
Top Bottom