bitsandbobs

Functions

pub fn bit_size(bitarray: BitArray) -> Int

Returns the size of a BitArray in bits by reading 8 bits at a time recursively This is a recursive function, so for larger bit arrays look to using bit_size_x with a custom starting size

pub fn bit_size_x(bitarray: BitArray, starting_size: Int) -> Int

A version of bit_size that allows you to specify the starting size

pub fn is_atleast_x_bits(
  bitarray: BitArray,
  mininum: Int,
) -> Bool

Determines if a BitArray is at least the specified size, will return negatives as False

pub fn map(
  bitarray: BitArray,
  every: Int,
  f: fn(BitArray) -> BitArray,
) -> BitArray

Splits a BitArray into a list of BitArrays of the specified size, performs an operation defined by the function on each BitArray and then appends the results back into a bit array

pub fn pad(
  bitarray: BitArray,
  amount_of_padding: Int,
) -> BitArray

Pads the start of a bitarray with zeros

pub fn split_every_x_bits(
  bitarray: BitArray,
  every: Int,
) -> List(BitArray)

Splits a BitArray into a list of BitArrays of the specified size Will leave trailing bits in the last BitArray if the BitArray is not evenly divisible by the specified size If the specified size is greater than the BitArray size, the BitArray will be returned as a singleton list

pub fn zip(
  first: BitArray,
  second: BitArray,
  every: Int,
) -> List(#(BitArray, BitArray))

Zips two BitArrays together by splitting them into BitArrays of the specified size and then list.zip-ping them together

Search Document