pub trait Associative: Magma { }
Expand description

結合法則を満たす。

二項演算 $\circ: M \times M \to M$ が結合法則を満たすことを示す。 $$ x, y, z \in M \implies (x \circ y) \circ z = x \circ (y \circ z). $$

Examples

use nekolib::traits::{Associative, Magma};
use nekolib::utils::OpMin;

let (x, y, z) = (2, 3, 4);
let op_min = OpMin::default();
assert_eq!(
    op_min.op(op_min.op(x, y), z),
    op_min.op(x, op_min.op(y, z)),
);

Implementors§

source§

impl<T> Associative for OpAdd<T>where T: Add<Output = T> + Eq + Sized + AddAssoc,

source§

impl<T> Associative for OpAddCount<T>where T: Add<Output = T> + Eq + Sized + AddAssoc,

source§

impl<T> Associative for OpAffine<T>where T: Add<Output = T> + Mul<Output = T> + Eq + Clone + Sized + AddAssoc,

source§

impl<T> Associative for OpGcd<T>where T: Gcd + Eq + Sized,

source§

impl<T> Associative for OpMax<T>where T: Ord + Eq + Sized,

source§

impl<T> Associative for OpMin<T>where T: Ord + Eq + Sized,

source§

impl<T> Associative for OpMul<T>where T: Mul<Output = T> + Eq + Sized + MulAssoc,

source§

impl<T: Eq, Op: Fn(T, T) -> T, Id: Fn() -> T> Associative for OpClosure<T, Op, Id>

source§

impl<const B: u64> Associative for OpRollHash<B>