Skip to main content

sum_over

Function sum_over 

Source
pub fn sum_over<'a, K, D, F>(domain: &D, f: F) -> Expr<'a>
where D: SumDomain<K> + ?Sized, F: FnMut(K) -> Expr<'a>,
Expand description

Sum an expression over every element of a domain.

Reads as the mathematical sum_{k in domain} f(k). The closure parameter is either decoded from the domain’s crate::set::IndexKey via FromIndexKey (when the domain is a Set) or yielded directly (when the domain is a slice of Copy keys).

§Panics

Panics if domain is empty, the resulting expression has no arena to attach to.