Jedynym wprowadzanym parametrem jest numer klasy, który otrzymasz. To jest to, co do tej pory miałem.Poprawna składnia instrukcji if w Haskell
myScore x = if x > 90
then let x = "You got a A"
if 80<x<90
then let x = "you got a B"
if 70<x<80
then let x = "You got a C"
if 60<x<90
then let x = "you got a D"
else let x = "You got a F"
To daje mi błąd „Błąd składniowy na wejściu jeśli`””, próbowałem też:
myScore x = (if x > 90 then "You got an A" | if 80 < x < 90 then "You got a B" | if 70 < x < 80 then "You got a D" | if 60 < x < 70 then "You got a D" else "You got a F")
ale to nie działało.
Trzeba dodać 'else' przed każdym' if'. –
Byłoby lepiej użyć tutaj strażników zamiast zagnieżdżonych 'if's. – hammar