Solve last task
This commit is contained in:
parent
7676005844
commit
4503171ec3
|
@ -114,7 +114,7 @@ circumference shape = case shape of
|
|||
{- Exercise
|
||||
Define a function
|
||||
'area :: Shape -> Float'
|
||||
to compute the area of any given shape. Use spearate
|
||||
to compute the area of any given shape. Use separate
|
||||
cases such as in 'Case 1' above.
|
||||
-}
|
||||
area :: Shape -> Float
|
||||
|
@ -151,7 +151,7 @@ myFunc x =
|
|||
x + 1
|
||||
|
||||
{- Where
|
||||
Where is the same as let, but it does not preceed but
|
||||
Where is the same as let, but it does not precede but
|
||||
follow a "main" declaration.
|
||||
-}
|
||||
six :: Integer
|
||||
|
|
|
@ -62,8 +62,10 @@ fIfElse n =
|
|||
|
||||
|
||||
fGuard :: Integer -> String
|
||||
fGuard = error "fixme"
|
||||
|
||||
fGuard x
|
||||
| (x `mod` 2 == 0) = "Even"
|
||||
| (x `mod` 3 == 0) = "Odd"
|
||||
| otherwise = "Oddity"
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Cases and pattern matching
|
||||
|
@ -113,12 +115,12 @@ circumference shape = case shape of
|
|||
{- Exercise
|
||||
Define a function
|
||||
'area :: Shape -> Float'
|
||||
to compute the area of any given shape. Use spearate
|
||||
to compute the area of any given shape. Use separate
|
||||
cases such as in 'Case 1' above.
|
||||
-}
|
||||
area :: Shape -> Float
|
||||
area = error "fixme"
|
||||
|
||||
area (Rectangle length width) = width * length
|
||||
area (Circle radius) = (radius ^ 2) * pi
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Let and where
|
||||
|
@ -149,7 +151,7 @@ myFunc x =
|
|||
x + 1
|
||||
|
||||
{- Where
|
||||
Where is the same as let, but it does not preceed but
|
||||
Where is the same as let, but it does not precede but
|
||||
follow a "main" declaration.
|
||||
-}
|
||||
six :: Integer
|
||||
|
|
Loading…
Reference in a new issue