Write a robot simulator.
A robot factory's test facility needs a program to verify robot movements.
The robots have three possible movements:
Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of {x,y} coordinates, e.g., {3,8}, with coordinates increasing to the north and east.
The robot then receives a number of instructions, at which point the testing facility verifies the robot's new position, and in which direction it is pointing.
To complete this exercise, you need to create the data type Robot
,
and implement the following functions:
bearing
coordinates
mkRobot
move
You will find a dummy data declaration and type signatures already in place, but it is up to you to define the functions and create a meaningful data type, newtype or type synonym.
Sign up to Exercism to learn and master Haskell with 107 exercises, and real human mentoring, all for free.