Fixed-width blocks of a padded bit list #
BitString.padBlocks n L x reads the bit list x as L / n consecutive blocks of n bits, block
i being BitString.listBlock n x i padded with false past the end of x. Only the first
(L / n) * n positions take part: the block count is the floor L / n, so when n ∤ L the last
L % n positions below L are dropped, and bits of x at positions ≥ (L / n) * n are ignored.
The reading is exact (padBlocks_getElem_apply reads every bit of x) when n ∣ L and
x.length ≤ L.
BitString.toBlocks n x is the case L = x.length: the consecutive blocks of n bits of x,
without an incomplete last block. A list made of whole blocks is the concatenation of its blocks
(flatMap_ofFn_toBlocks), so cutting is injective on such lists (toBlocks_injOn).
Main definitions #
Cslib.BitString.padBlocks: the firstL / npadded width-nblocks of a bit list.Cslib.BitString.toBlocks: the blocks ofnbits of a bit list.
Main results #
Cslib.BitString.length_padBlocks: there are exactlyL / nblocks.Cslib.BitString.padBlocks_getElem_apply: bitjof blockiis biti * n + jof the list, orfalsepast its end.Cslib.BitString.listRows_eq_map_ofFn_padBlocks:listRows (L / n) n xis the word view ofpadBlocks n L x.Cslib.BitString.flatMap_ofFn_toBlocks: a list of whole blocks is the concatenation of its blocks.Cslib.BitString.toBlocks_injOn,Cslib.BitString.toBlocks_append,Cslib.BitString.toBlocks_ofFn: cutting is injective on lists of whole blocks and commutes with appending after whole blocks.
The first L / n blocks of n bits of the bit list x: block i is listBlock n x i,
padded with false past the end of x. The block count is the floor L / n, so positions
≥ (L / n) * n are dropped; the reading is exact when n ∣ L and x.length ≤ L.