let w' = w { wdZeroesAcc = wdZeroesAcc w - 1 }
in
if wdZeroesAcc w' > 0 then
- let v' = New.modify (\mv → MV.unsafeWrite mv n 0) v
- n' = n + 1
+ let (# n', v' #) = appendWord 0 n v
in
go0 w' bs n' v'
else
( clearMedian $ fst $ wdEntropyData w'
, clearMedian $ snd $ wdEntropyData w' )
}
- v' = New.modify (\mv → MV.unsafeWrite mv n 0) v
- n' = n + 1
+ (# n', v' #)
+ = appendWord 0 n v
in
go0 w'' bs'' n' v'
else
= let (# code, bs' #)
= readCode bs (high - low)
low' = low + code
- a = if B.head bs' then
+ word = if B.head bs' then
fromIntegral $ complement low'
else
fromIntegral low'
bs'' = B.tail bs'
- v' = New.modify (\mv → MV.unsafeWrite mv n a) v
- n' = n + 1
+ (# n', v' #)
+ = appendWord word n v
in
go0 w bs'' n' v'
+ appendWord ∷ Int32 → Int → New v Int32 → (# Int, New v Int32 #)
+ appendWord word n v
+ = let v' = New.modify (\mv → MV.unsafeWrite mv n word) v
+ n' = n + 1
+ in
+ (# n', v' #)
+
getEntropy ∷ Int → WordsData → EntropyData
getEntropy n w
| isMono = fst $ wdEntropyData w