Translations:FP Homework 1/14/en

From Marek Běhálek Wiki
Jump to navigation Jump to search

10 - Turtle

Implement a function that will draw the movement of a turtle in a rectangular grid. It will be named draw and it will have one parameter - a list movements. Our turtle can move only horizontally or vertically. Each movement will be described by a pair (its type will be (Char, Int)), where the first character denotates a direction of this movement and the second its length. Possible directions are: left, right, up, and down. As the result, function draw returns a smallest possible rectangle with all turtle's movements. Each block from the grid will be represented with one character. If it was visited by our turtle, then it will be 'X', if it was not, then it will be ' '.