[英]Mapping list with function in Haskell
I am new to Haskell and I'm trying to change the position of a drawn path. 我是Haskell的新手,正在尝试更改绘制路径的位置。
let redPath = Path[Point 420 750, Point 420 550] red Solid
drawPicture 10 [redPath, movePictureObject (Vector 100 100)
redPath]
The functions movePictureObject and movePoint should change every point of the path with a given vector (100,100). 函数movePictureObject和movePoint应该使用给定的向量(100,100)更改路径的每个点。
movePoint :: Point -> Vector -> Point
movePoint (Point x y) (Vector xv yv)
= Point (x + xv) (y + yv)
movePictureObject :: Vector -> PictureObject ->PictureObject
movePictureObject vec (Path points colour lineStyle)
= Path map (movePoint (points vec)) red Solid
I am not sure of how to use the map function properly, I have read several posts here and watched other tutorials. 我不确定如何正确使用map函数,我在这里阅读了几篇文章,并观看了其他教程。
Thank you. 谢谢。
我的水晶球告诉我,您只需要在最后一行中(map movePoint (points vec))
而不是map (movePoint (points vec))
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.