20 lines
833 B
C#
20 lines
833 B
C#
namespace Bts.ArithmeticExpressions;
|
|
|
|
using System.Numerics;
|
|
|
|
public interface IArithmeticExpression {
|
|
IArithmeticExpression Add(IArithmeticExpression factor) => new Sum(this, factor);
|
|
IArithmeticExpression Divide(IArithmeticExpression other) => new Quotient(this, other);
|
|
IArithmeticExpression Multiply(IArithmeticExpression other) => new Product(this, other);
|
|
IArithmeticExpression Subtract(IArithmeticExpression other) => new Difference(this, other);
|
|
IArithmeticExpression Negate() => new AdditiveInverse(this);
|
|
object? Evaluate(IDictionary<string, object?> env);
|
|
}
|
|
|
|
public interface IArithmeticExpression<T> : IArithmeticExpression where T : INumber<T> {
|
|
new T Evaluate(IDictionary<string, object?> env);
|
|
|
|
object? IArithmeticExpression.Evaluate(IDictionary<string, object?> env) =>
|
|
Evaluate(env);
|
|
}
|