Я пытаюсь отобразить сетку линий с набором ячеек, которые заполняют квадраты в указанных линиях.
Я уже пытался объединить их как простые списки.
Это сетка линий.Он отображается правильно сам по себе.
grid = translate (fromIntegral width * (-0.5))
(fromIntegral height * (-0.5))
(pictures (concat [
[line [(i * unitWidth, 0.0)
,(i * unitWidth, fromIntegral height)]
,line [(0.0, i * unitHeight)
,(fromIntegral width, i * unitHeight)]
]
| i <- [1..gridDimension]]
)
)
Это набор единиц, которые нарисованы между линиями, также отображаются правильно самостоятельно.
units = pictures [translate ((x*unitWidth - unitWidth/2) + (fromIntegral width*(-0.5)))
((y*unitHeight - unitHeight/2) + (fromIntegral height*(-0.5)))
unit
| x <- [1..gridDimension], y <- [1..gridDimension]]
Мой основной метод:
main = display window backgroundColor units
Я могу обменять единицы на сетку в этом месте, и она отлично работает.Я также попробовал это:
main = display window backgroundColor (units++grid)
Вышла следующая ошибка:
40: error:
• Couldn't match expected type ‘[a0]’ with actual type ‘Picture’
• In the first argument of ‘(++)’, namely ‘grid’
In the third argument of ‘display’, namely ‘(grid ++ units)’
In the expression: display window backgroundColor (grid ++ units)
|
10 | main = display window backgroundColor (grid++units)
| ^^^^
/home/georg/Desktop/THM/6_semester/funktionale_programmierung/my/app/Main.hs:10:40: error:
• Couldn't match expected type ‘Picture’ with actual type ‘[a0]’
• In the third argument of ‘display’, namely ‘(grid ++ units)’
In the expression: display window backgroundColor (grid ++ units)
In an equation for ‘main’:
main = display window backgroundColor (grid ++ units)
|
10 | main = display window backgroundColor (grid++units)
| ^^^^^^^^^^^
/home/georg/Desktop/THM/6_semester/funktionale_programmierung/my/app/Main.hs:10:46: error:
• Couldn't match expected type ‘[a0]’ with actual type ‘Picture’
• In the second argument of ‘(++)’, namely ‘units’
In the third argument of ‘display’, namely ‘(grid ++ units)’
In the expression: display window backgroundColor (grid ++ units)
|
10 | main = display window backgroundColor (grid++units)
| ^^^^^