From 66de90437f64e532a51297dc233c57c2cda9a124 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 27 Mar 2023 20:23:37 +0200 Subject: Update fibonacci example and add `round` function --- library/src/math/delimited.rs | 18 ++++++++++++++++++ library/src/math/mod.rs | 1 + 2 files changed, 19 insertions(+) (limited to 'library') diff --git a/library/src/math/delimited.rs b/library/src/math/delimited.rs index 3be17eae..fe7d2d1e 100644 --- a/library/src/math/delimited.rs +++ b/library/src/math/delimited.rs @@ -141,6 +141,24 @@ pub fn ceil( delimited(body, '⌈', '⌉') } +/// Round an expression. +/// +/// ## Example +/// ```example +/// $ round(x/2) $ +/// ``` +/// +/// Display: Round +/// Category: math +/// Returns: content +#[func] +pub fn round( + /// The expression to round. + body: Content, +) -> Value { + delimited(body, '⌊', '⌉') +} + /// Take the absolute value of an expression. /// /// ## Example diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index 4e91dd51..b4a5b156 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -57,6 +57,7 @@ pub fn module() -> Module { math.define("norm", norm); math.define("floor", floor); math.define("ceil", ceil); + math.define("round", round); // Attachments and accents. math.define("attach", AttachElem::func()); -- cgit v1.2.3