DEV Community

Discussion on: Daily Challenge #233 - Get Planet Name by ID

Collapse
 
cipharius profile image
Valts Liepiņš

Haskell

getPlanetName :: Int -> Maybe String
getPlanetName i =
  case i of
    1 -> Just "Mercury"
    2 -> Just "Venus"
    3 -> Just "Earth"
    4 -> Just "Mars"
    5 -> Just "Jupiter"
    6 -> Just "Saturn"
    7 -> Just "Uranus"
    8 -> Just "Neptune"
    otherwise -> Nothing