Allow nested integrals

This commit is contained in:
bakk 2022-01-16 21:58:46 +01:00
parent 13e42c48a8
commit 1dd0377e31

View File

@ -597,10 +597,12 @@ fn build_fn_call(
log_base: Option<Expr>,
) -> Result<Expr, CalcError> {
let is_integral = identifier.pure_name == "integrate";
let prev_in_integral = context.in_integral;
if is_integral {
context.in_integral = true;
}
let prev_in_sum_prod = context.in_sum_prod;
let is_sum_prod = identifier.pure_name == "sum" || identifier.pure_name == "prod";
if is_sum_prod {
context.in_sum_prod = true;
@ -652,11 +654,11 @@ fn build_fn_call(
};
if is_integral {
context.in_integral = false;
context.in_integral = prev_in_integral;
}
if is_sum_prod {
context.in_sum_prod = false;
context.in_sum_prod = prev_in_sum_prod;
}
Ok(Expr::FnCall(identifier, arguments))