build hamming code display widget

This commit is contained in:
2024-07-19 20:50:33 -04:00
parent e216432a77
commit ef23b67688
8 changed files with 336 additions and 4 deletions

View File

@@ -44,7 +44,7 @@ hammingW = withAttr (attrName "hamming")
. map
( \(ns, v) -> foldr
(withAttr . attrName)
(str v)
(str [v])
ns
)
)

View File

@@ -26,9 +26,43 @@ License along with this program. If not, see
module Hamming.App.Widgets.Internal (hammingW') where
import Data.Bits ((.&.))
import Lens.Micro (_2, (^.), (%~))
import Hamming.App.Types
hammingW' :: AppState -> [[([String], String)]]
hammingW' = undefined
hammingW' :: AppState -> [[([String], Char)]]
hammingW' state = let
code = state^.hammingCode
in map
( map
( _2 %~
( \mask -> if code .&. mask == 0
then '0'
else '1'
)
)
)
[ [ ( ["zero", "check"], 0x0001 )
, ( ["check"], 0x0002 )
, ( ["check"], 0x0004 )
, ( [], 0x0008 )
]
, [ ( ["check"], 0x0010 )
, ( [], 0x0020 )
, ( [], 0x0040 )
, ( [], 0x0080 )
]
, [ ( ["check"], 0x0100 )
, ( [], 0x0200 )
, ( [], 0x0400 )
, ( [], 0x0800 )
]
, [ ( [], 0x1000 )
, ( [], 0x2000 )
, ( [], 0x4000 )
, ( [], 0x8000 )
]
]
--jl