我正在完成一项任务,需要一些帮助。这是最后一部分,但我真的很苦恼,不知道该如何着手。以下是问题:
Add a function render which takes an image and returns a string that, if printed, would give the diagrammatic representation of the image as illustrated below (making sure to include the one point border around all sides of the image). As an example, render t should return
".|...\n.xxx.\n-+x--\n.|...\n"
(where the points in the image are denoted 'x', the origin is denoted '+', and the horizontal and vertical axes are denoted '-' and '|' respectively):
.|... .xxx. -+x-- .|...
(String we produce by render t function can be printed by doing putStr (render t) to achieve above result).
image and t is just this:
type Point = (Int,Int) type Image = [Point] t :: Image t=[(0,1),(1,0),(1,1),(2,1)]
首先,我需要另一个函数来完成一些无法在渲染中完成的任务。我知道要查看y和x的最大/最小值以获取边界,并且我有一个函数可以做到这一点。我还有一个函数,可以在每n个字符后将换行符插入字符串中。
t=[(0,1),(1,0),(1,1),(2,1)]
转换为".|...\n.xxx.\n-+x--\n.|...\n"
的函数。 - Paperwaste(1,1000)
,我们的图像会变得非常大。 - Paperwaste