Page 1 of 1

Haskell language question! Declare data - data Direction = North | West | South | Eastderiving (Show,Eq) Task1) Writing

Posted: Tue Nov 16, 2021 6:53 am
by answerhappygod
Haskell language question!
Declare data -
data Direction = North | West | South | Eastderiving
(Show,Eq)
Task1)
Writing the implementation of function
sanitizeDirections :: [Direction] ->
[Direction]
sanitizeDirections (x:xs) = .....(Implementation task
what you have to do here)
Implementation specification:
You have to output a list of directions that make you go through
the same place twice or more and the final output has to follow the
order of direction like [North -> East -> South -> West]
instead of [North -> South -> West -> East]. Remove the
duplicates as well. Like below examples:
Input: [North,North,West,South,East,East,South,South,North]
Output: [North,East,South]