Skip to content

Commit

Permalink
add calls operation for mul
Browse files Browse the repository at this point in the history
  • Loading branch information
vanilla-extracts committed May 29, 2024
1 parent e5b5aaa commit adb9fbb
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/functions/mult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,83 @@ pub fn mult(

(Div(s1, s2), Null) => Div(s1.clone(), s2.clone()),

(Call(x, y), Call(a, b)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Call(a.clone(), b.clone())),
),

(Call(x, y), Null) => Call(x.clone(), y.clone()),

(Null, Call(x, y)) => Call(x.clone(), y.clone()),

(Call(x, y), Int(i)) => Mul(Box::from(Call(x.clone(), y.clone())), Box::from(Int(i))),

(Call(x, y), Float(i)) => Mul(Box::from(Call(x.clone(), y.clone())), Box::from(Float(i))),

(Call(x, y), Rational(i)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Rational(i)),
),

(Int(i), Call(x, y)) => Mul(Box::from(Call(x.clone(), y.clone())), Box::from(Int(i))),

(Float(i), Call(x, y)) => Mul(Box::from(Call(x.clone(), y.clone())), Box::from(Float(i))),

(Rational(i), Call(x, y)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Rational(i)),
),

(Call(x, y), Identifier(a)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Var(Box::from(Int(1)), 1, a.clone())),
),

(Identifier(a), Call(x, y)) => Mul(
Box::from(Var(Box::from(Int(1)), 1, a.clone())),
Box::from(Call(x.clone(), y.clone())),
),

(Call(x, y), Var(a, b, c)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Var(a.clone(), b, c.clone())),
),

(Var(a, b, c), Call(x, y)) => Mul(
Box::from(Var(a.clone(), b, c.clone())),
Box::from(Call(x.clone(), y.clone())),
),

(Call(x, y), Plus(a, b)) => Mul(
Box::from(Plus(a.clone(), b.clone())),
Box::from(Call(x.clone(), y.clone())),
),

(Plus(a, b), Call(x, y)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Plus(a.clone(), b.clone())),
),

(Call(x, y), Mul(a, b)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Mul(a.clone(), b.clone())),
),

(Mul(a, b), Call(x, y)) => Mul(
Box::from(Mul(a.clone(), b.clone())),
Box::from(Call(x.clone(), y.clone())),
),

(Call(x, y), Div(a, b)) => Mul(
Box::from(Call(x.clone(), y.clone())),
Box::from(Div(a.clone(), b.clone())),
),

(Div(a, b), Call(x, y)) => Mul(
Box::from(Div(a.clone(), b.clone())),
Box::from(Call(x.clone(), y.clone())),
),

_ => Identifier("@Those two values are incompatible with the * operator".to_string()),
}
}

0 comments on commit adb9fbb

Please sign in to comment.