MultiWayIf
if | <CONDITION1> -> <EXPRESSION1>
| <CONDITION2> -> <EXPRESSION2>
| ...
| <CONDITIONx> -> <EXPRESSIONx>
| otherwise -> <EXPRESSION>{-# LANGUAGE MultiWayIf #-}
module Practice where
...trackScore :: Float -> Float -> String
trackScore time avgTime =
if | time < avgTime -> "Great! Your time is " ++ show (avgTime - time)
++ " seconds below average!"
| time > avgTime -> "Your time is " ++ show (time - avgTime)
++ " seconds above average."
ghci> :r
[1 of 1] Compiling Practice ( practice.hs, interpreted )
*Practice> trackScore 10 10
"*** Exception: practice.hs:(74,1)-(76,89): Non-exhaustive patterns in
function trackScore"Last updated