diff --git a/crates/typst-library/src/compute/calc.rs b/crates/typst-library/src/compute/calc.rs index 9043e1f15..8a7c23ea6 100644 --- a/crates/typst-library/src/compute/calc.rs +++ b/crates/typst-library/src/compute/calc.rs @@ -445,8 +445,12 @@ pub fn fact( /// Calculates a permutation. /// +/// Returns the `k`-permutation of `n`, or the number of ways to choose `k` +/// items from a set of `n` with regard to order. +/// /// ```example -/// #calc.perm(10, 5) +/// $ "perm"(n, k) &= n!/((n - k)!) \ +/// "perm"(5, 3) &= #calc.perm(5, 3) $ /// ``` #[func(title = "Permutation")] pub fn perm( @@ -482,6 +486,9 @@ fn fact_impl(start: u64, end: u64) -> Option { /// Calculates a binomial coefficient. /// +/// Returns the `k`-combination `n`, or the number of ways to choose `k` +/// items from a set of `n` without regard to order. +/// /// ```example /// #calc.binom(10, 5) /// ``` @@ -779,6 +786,9 @@ pub fn odd( /// Calculates the remainder of two numbers. /// +/// The value `calc.rem(x, y)` always has the same sign as `x`, and is smaller +/// in magnitude than `y`. +/// /// ```example /// #calc.rem(20, 6) \ /// #calc.rem(1.75, 0.5) @@ -796,11 +806,12 @@ pub fn rem( Ok(dividend.apply2(divisor.v, Rem::rem, Rem::rem)) } -/// Calculates the quotient of two numbers. +/// Calculates the quotient (floored division) of two numbers. /// /// ```example -/// #calc.quo(14, 5) \ -/// #calc.quo(3.46, 0.5) +/// $ "quo"(a, b) &= floor(a/b) \ +/// "quo"(14, 5) &= #calc.quo(14, 5) \ +/// "quo"(3.46, 0.5) &= #calc.quo(3.46, 0.5) $ /// ``` #[func(title = "Quotient")] pub fn quo(