blob: b69aa419ffdac31ab90d60a2019710e68a56fe61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module Lattice
( LatticeCell (..)
, Lattice
, LatticeRule
, updateLattice
) where
data LatticeCell a b = LatticeCell { kind :: a, flags :: b } deriving (Show, Eq)
type Lattice a b = [[LatticeCell a b]]
type LatticeRule a b = Lattice a b -> Int -> Int -> LatticeCell a b
updateLattice :: (Enum a) => Lattice a b -> [LatticeRule a b] -> Lattice a b
updateLattice lattice rules =
let
mapRow = \(row, y) -> map
(\((LatticeCell k _), x) ->
let rule = rules !! (fromEnum k)
in rule lattice x y
)
(zip row [0..])
in map mapRow (zip lattice [0..])
|