bitsandbobs/ints

Functions

pub fn add(
  first: BitArray,
  second: BitArray,
  size: Int,
) -> BitArray

Adds two BitArrays together by splitting them into BitArrays of the specified size and then adding them together, finally concatenating them back into a BitArray

pub fn from_bitarray(bitarray: BitArray) -> Int

Converts a BitArray to an Int A short hand for bitsandbobs.bit_size into from_x_bits

pub fn from_x_bits(
  bitarray: BitArray,
  bit_count: Int,
) -> Result(Int, Nil)

Reads a BitArray into an Int by reading the specified number of bits If the BitArray is not long enough, returns an Error

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

A short hand for map_every_x_bits with a size of 8

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

Maps a function over a BitArray by reading the specified number of bits at a time

pub fn to_bitarray(int: Int) -> BitArray

Converts an Int to a BitArray

Search Document