diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-10-27 19:04:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-27 18:04:55 +0000 |
| commit | be7cfc85d08c545abfac08098b7b33b4bd71f37e (patch) | |
| tree | f4137fa2aaa57babae1f7603a9b2ed7e688f43d8 /crates/typst-library/src/math/root.rs | |
| parent | b8034a343831e8609aec2ec81eb7eeda57aa5d81 (diff) | |
Split out four new crates (#5302)
Diffstat (limited to 'crates/typst-library/src/math/root.rs')
| -rw-r--r-- | crates/typst-library/src/math/root.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/typst-library/src/math/root.rs b/crates/typst-library/src/math/root.rs new file mode 100644 index 00000000..e25c6d42 --- /dev/null +++ b/crates/typst-library/src/math/root.rs @@ -0,0 +1,35 @@ +use typst_syntax::Span; + +use crate::foundations::{elem, func, Content, NativeElement}; +use crate::math::Mathy; + +/// A square root. +/// +/// ```example +/// $ sqrt(3 - 2 sqrt(2)) = sqrt(2) - 1 $ +/// ``` +#[func(title = "Square Root")] +pub fn sqrt( + /// The call span of this function. + span: Span, + /// The expression to take the square root of. + radicand: Content, +) -> Content { + RootElem::new(radicand).pack().spanned(span) +} + +/// A general root. +/// +/// ```example +/// $ root(3, x) $ +/// ``` +#[elem(Mathy)] +pub struct RootElem { + /// Which root of the radicand to take. + #[positional] + pub index: Option<Content>, + + /// The expression to take the root of. + #[required] + pub radicand: Content, +} |
