0

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.

1
  • 1
    What is Path? What is Point? What is a PictureObject? What is Vector? Why is this tagged dictionary? And what is your actual question? Commented Mar 14, 2017 at 7:05

1 Answer 1

1

My crystal ball tells me, that you just need (map movePoint (points vec)) instead of map (movePoint (points vec)) in the last line.

Sign up to request clarification or add additional context in comments.

2 Comments

(map (\p -> movePoint p vec) points) seems more likely to me.
That did it @Daniel Wagner

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.