Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 667 Bytes

README.md

File metadata and controls

23 lines (17 loc) · 667 Bytes

cas-compute

This subcrate provides the computer algebra facilities for cas-rs.

cas-compute is split further into two submodules, numerical and symbolic.

Simplification

use cas_compute::numerical::consts::int;
use cas_compute::symbolic::{expr::{Expr, Primary}, simplify};
use cas_parser::parser::{ast::Expr as AstExpr, Parser};

let mut parser = Parser::new("x + x + x");
let ast_expr = parser.try_parse_full::<AstExpr>().unwrap();
let simplified = simplify(&ast_expr.into());

// `x + x + x = 3x`
assert_eq!(simplified, Expr::Mul(vec![
    Expr::Primary(Primary::Integer(int(3))),
    Expr::Primary(Primary::Symbol("x".to_string())),
]));