Skip to content

Commit 0bd59b7

Browse files
committed
#224 - Introduce simplification rules
1 parent 8824554 commit 0bd59b7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace xFunc.Maths.Analyzers2.Rules;
2+
3+
public class ExpLnUnaryRule : Rule<Exp>
4+
{
5+
protected override Result ExecuteInternal(Exp expression, RuleContext context)
6+
=> expression.Argument switch
7+
{
8+
Ln ln => Handled(ln.Argument),
9+
_ => NotHandled(),
10+
};
11+
12+
public override string Name => "Exponential Ln Rule";
13+
14+
public override string Description => "";
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace xFunc.Maths.Analyzers2.Rules;
2+
3+
public class ExpUnaryRule : UnaryRule<Exp>
4+
{
5+
protected override Exp Create(IExpression argument)
6+
=> new Exp(argument);
7+
8+
public override string Name => "Exponential Unary Rule";
9+
10+
public override string Description => "";
11+
}

xFunc.Maths/Analyzers2/Simplifier2.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public Simplifier2()
4444
.WithNext(new DivConstUnit())
4545
.WithNext(new DivBySameExpression())
4646
.WithNext(new DivGroupRule()))
47+
.WithChain<Exp>(builder => builder
48+
.WithRule(new ExpUnaryRule())
49+
.WithNext(new ExpLnUnaryRule()))
4750
.WithChain<Sub>(builder => builder
4851
.WithRule(new SubBinaryRule())
4952
.WithNext(new SubZeroRule())

0 commit comments

Comments
 (0)