Haskell - Rotate coordinate list into ASCII graph?

I am trying to complete a task. This is the last question about the appointment, and I'm going to do it for a while with little success. I need to turn the image into an ASCII graph, where

type Point = (Int, Int)
type Image = [Point]

I need to write a function that takes an image and returns a string. The result should be something like ". | ... \ n.xxx. \ N- + x - \ n. | ... \ n", which when output using putStr looks like

.|...
.xxx.
-+x--
.|...

With the beginning, denoted by +, the axis | and -, and the points x '.

The graph should always have a 1-point border around the coordinates, so when I print the graph, I need to know the borders of the coordinates. I have a function to get them.

I also wrote a function, split, that takes a String and an integer, and inserts \ n at every nth interval. The way I thought about resolving the issue was to create an empty graph with the correct positions for the axes, and then pass an empty graph to a new function to insert points.

Can anyone help me with this? Sorry if it is fuzzy, I can provide more detailed information that you may require.

+2
source share
2 answers

Here are some things to think about:

  • , ? , , . . , type, FImage. , (, ).
  • , FImage. , . ?
  • , FImage Point, FImage x .
  • . , : ?
  • FImage , String. , List List.
  • . ! . ( ). Haskell , foldl foldr, ( ).
  • : -)

!

+1

, .

  • , , ?
  • , ?
  • , , ?
0

All Articles