[Haskell-cafe] Haskell beginner questions
jim at sdf-eu.org
Tue Oct 24 07:47:11 EDT 2006
> Hi all, I'm pretty much new to Haskell however I'm stuck on something
> which is that I'm trying to create a function called display where I type
> in a DVD name, e.g. dvd1, it returns d (String) and the multiplication of
> q (Int) and i (Double)
> Here's what I've done so far:
> type Film = (Int,String,Int,Double)
> dvd1 :: Film
> dvd1 = (1, "Space", 5, 9.99)
> display :: Product -> String
> display (c,d,q,i) = d
> My display function only shows the string but unfortunately I'm stuck on
> how to get the display function to multiply q (Int) and i (Double)
> together and display it next to d.
> Can someone help me out please? :)
I'd recommend a tutorial like
> display :: Film -> String
> display (c,d,q,i) = d ++ " " ++ show (fromIntegral q * i)
q needs to be converted first and show will convert the result to a string.
View this message in context: http://www.nabble.com/Haskell-beginner-questions-tf2500050.html#a6971248
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe