简体   繁体   中英

Mapping list with function in Haskell

I am new to Haskell and I'm trying to change the position of a drawn path.

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).

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.

Thank you.

我的水晶球告诉我,您只需要在最后一行中(map movePoint (points vec))而不是map (movePoint (points vec))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM