Reputation: 22777
Here is my code
quadtreeToPic QNode x y w avg Q4(q1 q2 q3 q4) = array ((0,0) (w-1,w-1)) (concat (map quadtreeToPic [q1, q2, q3, q4]))
Basically, a Quadtree
is x y w avg QChildren
where QChildren
is qither Q0
or Q4 Quadtree Quadtree Quadtree Quadtree
.
When I do what I tried above, I get this error
Quadtree.hs:13:34: error: Parse error in pattern: q1
|
13 | quadtreeToPic QNode x y w avg Q4(q1 q2 q3 q4) = array ((0,0) (w-1,w-1)) (concat (map quadtreeToPic [q1, q2, q3, q4]))
| ^^^^^^^^^^^
Why is this?
Upvotes: 1
Views: 38
Reputation: 477794
The Q4
dataconstructor and the parameters are a single parameter, here, so you need to add brackets including the Q4
data constructor. For example:
quadtreeToPic QNode x y w avg (Q4 q1 q2 q3 q4) = ...
Note that you can use concatMap :: (a -> [b]) -> [a] -> [b]
here instead of concat (map ...)
:
... concatMap quadtreeToPic [q1, q2, q3, q4]
Upvotes: 3