[Haskell-cafe] Haskell-Cafe Digest, Vol 99, Issue 9

yrazes yrazes at gmail.com
Fri Nov 4 07:07:06 CET 2011


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 at gmail.com> wrote:

> On 4 November 2011 16:21, yrazes <yrazes at gmail.com> wrote:
> > Hi
> > This is a very simple basic case, but I have a little trouble with
> 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 at gmail.com
> IvanMiljenovic.wordpress.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111104/46f40f34/attachment.htm>


More information about the Haskell-Cafe mailing list