blops

Bitwise operators, applied to BitArrays.

import gleeunit/should
import blops

// bitwise or
blops.bor(<<0b10101010>>, <<0b10111011>>)
|> should.equal(<<0b10111011>>)
// bitwise and
blops.band(<<0b10101010>>, <<0b10111011>>)
|> should.equal(<<0b10101010>>)
// bitwise xor (not equal)
blops.bneq(<<0b10101010>>, <<0b10111011>>)
|> should.equal(<<0b00010001>>)
// bitwise reverse implication 
blops.brevi(<<0b10101010>>, <<0b10111011>>)
|> should.equal(<<0b11101110>>)

Binary Operators

All the binary operators here come in three flavors:

Unary Operator

There is also one unary operator: unary negation, bnot().

Values

pub fn band(a: BitArray, b: BitArray) -> BitArray

bitwise and

pub fn band_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bandx(a: BitArray, b: BitArray) -> BitArray
pub fn beq(a: BitArray, b: BitArray) -> BitArray

bitwise equal

pub fn beq_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn beqx(a: BitArray, b: BitArray) -> BitArray
pub fn bimpl(a: BitArray, b: BitArray) -> BitArray

bitwise implication (if-then)

pub fn bimpl_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bimplx(a: BitArray, b: BitArray) -> BitArray
pub fn bnand(a: BitArray, b: BitArray) -> BitArray

bitwise not-and (nand)

pub fn bnand_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bnandx(a: BitArray, b: BitArray) -> BitArray
pub fn bneq(a: BitArray, b: BitArray) -> BitArray

bitwise not-equal (xor)

pub fn bneq_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bneqx(a: BitArray, b: BitArray) -> BitArray
pub fn bnimpl(a: BitArray, b: BitArray) -> BitArray

bitwise not-implies

pub fn bnimpl_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bnimplx(a: BitArray, b: BitArray) -> BitArray
pub fn bnor(a: BitArray, b: BitArray) -> BitArray

bitwise not-or (nor, neither)

pub fn bnor_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bnorx(a: BitArray, b: BitArray) -> BitArray
pub fn bnot(a: BitArray) -> BitArray

Unary bitwise negation.

pub fn bnrevi(a: BitArray, b: BitArray) -> BitArray

bitwise not-reverse-implies

pub fn bnrevi_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn bnrevix(a: BitArray, b: BitArray) -> BitArray
pub fn bor(a: BitArray, b: BitArray) -> BitArray

bitwise or

pub fn bor_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn borx(a: BitArray, b: BitArray) -> BitArray
pub fn brevi(a: BitArray, b: BitArray) -> BitArray

bitwise reverse implication (only-if, when)

pub fn brevi_try(
  a: BitArray,
  b: BitArray,
) -> Result(BitArray, errors.LengthMismatch)
pub fn brevix(a: BitArray, b: BitArray) -> BitArray
✨ Search Document