Reputation: 1
Im trying to replicate the example of the book "Learn a Haskell for a Great Good", with the use of let
and in
.
The thing is that, although I write the same code in the same way, it doesn't work and shows me a failure with the second "=" in the second variable.
Can anyone help me with this issue?
cylinder :: (RealFloat a) => a ->a ->a
cylinder r h =
let sideArea = 2*pi*r*h
topArea = pi*r^2
in sideArea + 2*topArea
Upvotes: 0
Views: 142
Reputation: 126
This worked for me:
Prelude CA> let cylinder r h =
Prelude CA| let sideArea = 2*pi*r*h
Prelude CA| topArea = pi*r^2
Prelude CA| in sideArea + 2*topArea
Prelude CA|
Prelude CA> cylinder 5 9
439.822971502571
I guess it's simply an indentation problem
<interactive>:48:5: parse error (possibly incorrect indentation)
Upvotes: 1