diff options
author | sanine <sanine.not@pm.me> | 2023-11-29 20:48:46 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-29 20:48:46 -0600 |
commit | 587cbadb3e6388c29454ab41c120757f108918fa (patch) | |
tree | 1fae09c76fce21b3f1b4ff23653dc5aa2f9067ac /src | |
parent | 4facdd8a1a5f141b158acbe1959da3d10d4c8ce9 (diff) |
implement updateLattice
Diffstat (limited to 'src')
-rw-r--r-- | src/Lattice.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Lattice.hs b/src/Lattice.hs new file mode 100644 index 0000000..b69aa41 --- /dev/null +++ b/src/Lattice.hs @@ -0,0 +1,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..]) |