evalExpr :: Expr -> Screen -> Screen — screen is essentially [[Int]]
evalExpr e s =
case e of
(Rect r c ) -> evalRect r c s
(RotRow r by) -> evalRotRow r by s
(RotCol c by) -> evalRotCol c by s
(NOP ) -> id s
rotating a row was simple enough, code to rotate column a bit untidy and not very nice. The
evalRect - which sets values to one in the rectangle of size r x c starting at (0,0) top left - triggered the original question.
At this point my knowledge of Haskell is being pushed (which is good) but I have a feeling that
my approach is not ‘correct’ once it gets beyond the parsing. Should each of the evalRect, evalRotRow and evalRotCol be called with a Screen (i.e. the grid at the root of this question)?
Is the state monad a fit for this problem?
Should I change my approach or is using vector the way forward?
Many thanks
Mike