
Thank you so much Ivan!!! main :: IO ( ) main = let a = 8 b = 3 c = 15 in print(b / a * c) This code works!!! :) Julita On Fri, Nov 4, 2011 at 12:53 AM, Ivan Lazar Miljenovic < ivan.miljenovic@gmail.com> wrote:
Hi This is a very simple basic case, but I have a little trouble with
On 4 November 2011 16:21, yrazes
wrote: this... I hope somebody can help me
First of all, it would help if you said what your actual trouble is.
main :: IO() main = return :: f
The "return :: f" bit here doesn't make any sense:
* :: is used in type signatures, not as an operator in code; you shouldn't need it (assuming your definition of f below is meant to be there).
tipos :: Int -> Int -> Int -> Float tipos a b c f = b / a * c where (a,b,c) = (8,3,15)
Your definition of tipos isn't complete... what you've actually defined is a new top-level value `f' (which is of type Fractional a => a). You need to actually have "tipos a b c" _equal_ something.
Now, if you want to calculate "b/a*c" for inputs a, b and c, try something like this:
import System.Environment(getArgs)
main :: IO () main = do [a,b,c] <- getArgs print $ tipos (read a) (read b) (read c)
tipos :: Int -> Int -> Int -> Double tipos a b c = fromIntegral b / fromIntegral b * fromIntegral c
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com