Pads

Pads are bit-strings encoded as non-zero natural numbers. Pads are not data-jetted, since the direct nat works perfectly. Pads are encoded least-significant-bit-first, with the high bit used to indicate the end of the bit-array.

p#{}          == 0b1 ; 1
p#{00}        == 0b100 ; 4
p#{01}        == 0b110 ; 6
p#{111000}    == 0b1000111 ; %G

All of the pad operations coerce their inputs into pads, and always return pads.

The REPL will print pads as their natural number representation by default. Use padShowLit to coerce the output into the bit-string format used here.

emptyPad

Represents an empty pad.

emptyPad    == 1

toPad

Coerces a value into a non-zero natural number (pad).

toPad 0     == 1
toPad 1     == 1
toPad 3     == 3

padNat

Converts a pad to a natural number, dropping all trailing zeros.

natPad

Converts a natural number into a pad with a specific minimum bit-width.

padLen

Returns the length of a pad (number of bits).

padWeld

Concatenates two pads.

padCat

Concatenates a row of pads.

padFlat

Flattens and concatenates a nested structure of pads.

padSplitAt

Splits a pad at a given index.

padIdx

Returns the nth bit from a pad.

padGet

Alias for padIdx, but with arguments flipped.

padSet

Sets the nth bit in a pad using a Bit.

padMapWithKey

Maps a function over the bits in a pad, providing both the index and the bit value.

padMap

Maps a function over the bits in a pad, coercing outputs to bits.

padComplement

Complements all bits in a pad.

showPadStr

Converts a pad to its string representation.

showPadLit

Converts a pad to its Rex literal representation.

Last updated