pub struct Magma<'a, T> { /* private fields */ }Expand description
A set with an associated binary operation.
This is a representation of the simplest algebraic structure: the magma.
There are no specific properties required of its components, so its
construction involves nothing more than a set (specifically an
AlgaeSet and a binary operation (anything implementing
BinaryOperation).
Examples
use algae_rs::algaeset::AlgaeSet;
use algae_rs::mapping::{BinaryOperation, AbelianOperation};
use algae_rs::magma::{Magmoid, Magma};
let mut add = AbelianOperation::new(&|a, b| a + b);
let mut magma = Magma::new(
AlgaeSet::<i32>::all(),
&mut add
);
let magma_sum = magma.with(1, 2);
assert!(magma_sum.is_ok());
assert!(magma_sum.unwrap() == 3);