1use crate::parser::{LispExpr, MathML};
2
3impl MathML {
4 pub fn addition(args: &[LispExpr]) -> Self {
5 let args_mathml: Vec<String> = args.iter()
6 .map(|arg| MathML::from(arg).to_string())
7 .collect();
8
9 format!("<mrow>{}</mrow>", args_mathml.join("<mo>+</mo>")).into()
10 }
11
12 pub fn subtraction(args: &[LispExpr]) -> Self {
13 let args_mathml: Vec<String> = args.iter()
14 .map(|arg| MathML::from(arg).to_string())
15 .collect();
16
17 format!("<mrow>{}</mrow>", args_mathml.join("<mo>-</mo>")).into()
18 }
19
20 pub fn multiplication(args: &[LispExpr]) -> Self {
21 let args_mathml: Vec<String> = args.iter()
22 .map(|arg| MathML::from(arg).to_string())
23 .collect();
24
25 format!("<mrow>{}</mrow>", args_mathml.join("<mo>*</mo>")).into()
26 }
27
28 pub fn division(args: &[LispExpr]) -> Self {
29 let args_mathml: Vec<String> = args.iter()
30 .map(|arg| MathML::from(arg).to_string())
31 .collect();
32
33 format!("<mrow>{}</mrow>", args_mathml.join("<mo>/</mo>")).into()
34 }
35
36 pub fn matrix(args: &[LispExpr]) -> Self {
37 let rows_mathml = args.iter().map(|row| {
38 if let LispExpr::List(cells) = row {
39 let cells_mathml = cells.iter()
40 .map(|cell| format!("<mtd>{}</mtd>", MathML::from(cell).to_string()))
41 .collect::<Vec<String>>()
42 .join("");
43 format!("<mtr>{}</mtr>", cells_mathml)
44 } else {
45 "<mtr><mtd>Error: matrix row must be a list</mtd></mtr>".to_string()
46 }
47 }).collect::<Vec<String>>().join("");
48
49 format!("<mrow><mo>[</mo><mtable>{}</mtable><mo>]</mo></mrow>", rows_mathml).into()
50 }
51
52 pub fn fraction(_args: &[LispExpr]) -> Self {
53 unimplemented!()
54 }
55
56 pub fn subscript(_args: &[LispExpr]) -> Self {
57 unimplemented!()
58 }
59
60 pub fn superscript(_args: &[LispExpr]) -> Self {
61 unimplemented!()
62 }
63
64 pub fn vector(_args: &[LispExpr]) -> Self {
65 unimplemented!()
66 }
67
68 pub fn derivative(_args: &[LispExpr]) -> Self {
69 unimplemented!()
70 }
71
72 pub fn integral(_args: &[LispExpr]) -> Self {
73 unimplemented!()
74 }
75
76 pub fn limit(_args: &[LispExpr]) -> Self {
77 unimplemented!()
78 }
79
80 pub fn sum(_args: &[LispExpr]) -> Self {
81 unimplemented!()
82 }
83
84 pub fn abs(_args: &[LispExpr]) -> Self {
85 unimplemented!()
86 }
87
88 pub fn sqrt(_args: &[LispExpr]) -> Self {
89 unimplemented!()
90 }
91
92 pub fn nth_root(_args: &[LispExpr]) -> Self {
93 unimplemented!()
94 }
95
96}