put margins on Hamming widget

This commit is contained in:
2024-07-20 16:27:41 -04:00
parent 1565c1fe99
commit 7531cf192f
2 changed files with 119 additions and 19 deletions

View File

@@ -24,6 +24,8 @@ License along with this program. If not, see
|-}
{-# LANGUAGE TupleSections #-}
module Hamming.App.Widgets.Internal (hammingW') where
import Data.Bits ((.&.))
@@ -33,6 +35,15 @@ import Hamming.App.Types
hammingW' :: AppState -> [[([String], Char)]]
hammingW' state = let
header = ([], ' ') : map (["margin"],) ['0'..'3']
body = hammingBody state
in header : zipWith
(\n row -> (["margin"], n) : row)
['0'..'3']
body
hammingBody :: AppState -> [[([String], Char)]]
hammingBody state = let
code = state^.hammingCode
in map
( map