Skip to content

Commit

Permalink
Deprecate Rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Dec 24, 2017
1 parent 7774064 commit a39a41e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 29 deletions.
3 changes: 0 additions & 3 deletions expreduce/builtin.go
Expand Up @@ -19,9 +19,6 @@ type Definition struct {
ExpreduceSpecific bool
Details string

// Regular rules to define. This should never include a map, as maps have
// indeterminate iteration.
Rules []Rule
// Map symbol to Eval() function
legacyEvalFn (func(*Expression, *EvalState) Ex)
SimpleExamples []TestInstruction
Expand Down
3 changes: 0 additions & 3 deletions expreduce/builtin_manip.go
Expand Up @@ -37,9 +37,6 @@ func GetManipDefinitions() (defs []Definition) {
})
defs = append(defs, Definition{
Name: "Distribute",
Rules: []Rule{
{"Distribute[e_]", "Distribute[e, Plus]"},
},
legacyEvalFn: func(this *Expression, es *EvalState) Ex {
if len(this.Parts) != 3 {
return this
Expand Down
7 changes: 0 additions & 7 deletions expreduce/builtin_power.go
Expand Up @@ -120,13 +120,6 @@ func GetPowerDefinitions() (defs []Definition) {
// This function is not implemented to a satisfiable extent. Do not
// document it yet.
OmitDocumentation: true,
SimpleExamples: []TestInstruction{
&TestComment{"`PowerExpand` can expand nested log expressions:"},
&SameTest{"Log[a] + e (Log[b] + d Log[c])", "PowerExpand[Log[a (b c^d)^e]]"},
},
Rules: []Rule{
{"PowerExpand[exp_]", "exp //. {Log[x_ y_]:>Log[x]+Log[y],Log[x_^k_]:>k Log[x]}"},
},
})
defs = append(defs, Definition{Name: "Expand"})
defs = append(defs, Definition{
Expand Down
10 changes: 0 additions & 10 deletions expreduce/evalstate.go
Expand Up @@ -32,16 +32,6 @@ func (this *EvalState) Load(def Definition) {
def.Name = this.GetStringDef("System`$Context", "") + def.Name
this.MarkSeen(def.Name)
EvalInterp("$Context = \"Private`\"", this)
// TODO: do we really need SetDelayed here, or should we just write to
// downvalues directly? If we did this, we could potentially remove the
// "bootstrap" attribute that SetDelayed has.
for _, rule := range def.Rules {
(NewExpression([]Ex{
NewSymbol("System`SetDelayed"),
Interp(rule.Lhs, this),
Interp(rule.Rhs, this),
})).Eval(this)
}

if len(def.Usage) > 0 {
(NewExpression([]Ex{
Expand Down
12 changes: 6 additions & 6 deletions expreduce/resources.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions expreduce/resources/manip.m
Expand Up @@ -181,6 +181,8 @@
};

Distribute::usage = "`Distribute[e]` distributes the function over the `Plus` expressions.";
Distribute[e_] := Distribute[e, Plus];
Attributes[Distribute] = {Protected};
Tests`Distribute = {
ESimpleExamples[
ESameTest[a c+b c+a d+b d, Distribute[(a+b)*(c+d)]],
Expand Down
9 changes: 9 additions & 0 deletions expreduce/resources/power.m
Expand Up @@ -761,3 +761,12 @@
ESameTest[a, Factor[a]],
]
};

PowerExpand[exp_] := exp //. {Log[x_ y_]:>Log[x]+Log[y],Log[x_^k_]:>k Log[x]};
Attributes[PowerExpand] = {Protected};
Tests`PowerExpand = {
ESimpleExamples[
EComment["`PowerExpand` can expand nested log expressions:"],
ESameTest[Log[a] + e (Log[b] + d Log[c]), PowerExpand[Log[a (b c^d)^e]]]
]
};

0 comments on commit a39a41e

Please sign in to comment.