How can just write flipv
one time applying it to each element of list [se, sq, nw, ne]
, giving the result (not as a list of course) to the Q
constructor?
data (Eq a, Show a) => QT a = C a | Q (QT a) (QT a) (QT a) (QT a)
deriving (Eq, Show)
flipv :: (Eq a, Show a) => QT a -> QT a
flipv (C a) = C a
flipv (Q nw ne se sw) = Q (flipv se) (flipv sw) (flipv nw) (flipv ne)
EDIT: note this actually wrong because the pointers should be: NW NE SW SE.
There is no particularly simple or compact method, but you could try this: