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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply