Simplify query argument.

Truth table and array utils.

Count distinct atomic values.
This commit is contained in:
Martin Berg Alstad
2024-06-08 21:41:30 +02:00
parent 912cf6f1e5
commit f3fa0334c2
7 changed files with 252 additions and 10 deletions

View File

@ -42,13 +42,16 @@ struct SimplifyResponse {
// TODO
async fn simplify(Path(path): Path<String>, query: Query<QueryOptions>, accept_language: Option<AcceptLanguage>) -> Response {
if let Ok(expression) = Expression::try_from(path.as_str()) {
let simplified = expression.simplify();
if let Ok(mut expression) = Expression::try_from(path.as_str()) {
let before = expression.to_string();
if query.simplify {
expression = expression.simplify();
}
Json(SimplifyResponse {
before: expression.to_string(),
after: simplified.to_string(),
before,
after: expression.to_string(),
order_of_operations: vec![], // TODO
expression: simplified,
expression,
}).into_response()
} else {
(StatusCode::BAD_REQUEST, "Invalid expression").into_response()