diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-03 12:40:14 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-03 12:40:14 +0100 |
| commit | e460da1ce7436242e9c356a23b97d6a474085544 (patch) | |
| tree | 2fcc821a05813661f5e3687c26c8626346322fff /library/src/math/group.rs | |
| parent | e38839c28730ae99cd4ad357e588b5e7e840badc (diff) | |
Split up math library
Diffstat (limited to 'library/src/math/group.rs')
| -rw-r--r-- | library/src/math/group.rs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/library/src/math/group.rs b/library/src/math/group.rs new file mode 100644 index 00000000..4a55e0e8 --- /dev/null +++ b/library/src/math/group.rs @@ -0,0 +1,71 @@ +use super::*; + +/// # Floor +/// A floored expression. +/// +/// ## Example +/// ``` +/// $ floor(x/2) $ +/// ``` +/// +/// ## Parameters +/// - body: Content (positional, required) +/// The expression to floor. +/// +/// ## Category +/// math +#[func] +#[capable(Texify)] +#[derive(Debug, Hash)] +pub struct FloorNode(pub Content); + +#[node] +impl FloorNode { + fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { + Ok(Self(args.expect("body")?).pack()) + } +} + +impl Texify for FloorNode { + fn texify(&self, t: &mut Texifier) -> SourceResult<()> { + t.push_str("\\left\\lfloor "); + self.0.texify(t)?; + t.push_str("\\right\\rfloor "); + Ok(()) + } +} + +/// # Ceil +/// A ceiled expression. +/// +/// ## Example +/// ``` +/// $ ceil(x/2) $ +/// ``` +/// +/// ## Parameters +/// - body: Content (positional, required) +/// The expression to ceil. +/// +/// ## Category +/// math +#[func] +#[capable(Texify)] +#[derive(Debug, Hash)] +pub struct CeilNode(pub Content); + +#[node] +impl CeilNode { + fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { + Ok(Self(args.expect("body")?).pack()) + } +} + +impl Texify for CeilNode { + fn texify(&self, t: &mut Texifier) -> SourceResult<()> { + t.push_str("\\left\\lceil "); + self.0.texify(t)?; + t.push_str("\\right\\rceil "); + Ok(()) + } +} |
