Skip to content

Commit

Permalink
Unexport.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Oct 22, 2018
1 parent b9f16a4 commit c8107f1
Show file tree
Hide file tree
Showing 39 changed files with 238 additions and 238 deletions.
52 changes: 26 additions & 26 deletions expreduce/builtin.go
Expand Up @@ -16,7 +16,7 @@ type Definition struct {
// SetDelayed, we define it first.
Bootstrap bool
OmitDocumentation bool
ExpreduceSpecific bool
expreduceSpecific bool
Details string

// Map symbol to Eval() function
Expand Down Expand Up @@ -94,7 +94,7 @@ func ToTestInstructions(tc expreduceapi.ExpressionInterface) []TestInstruction {
return instructions
}

func (def *Definition) AnnotateWithDynamicTests(es expreduceapi.EvalStateInterface) {
func (def *Definition) annotateWithDynamicTests(es expreduceapi.EvalStateInterface) {
tests, testsDef := es.GetSymDef("Tests`" + def.Name)
if !testsDef {
return
Expand Down Expand Up @@ -138,7 +138,7 @@ func (def *Definition) AnnotateWithDynamicTests(es expreduceapi.EvalStateInterfa
}
}

func (def *Definition) AnnotateWithDynamicUsage(es expreduceapi.EvalStateInterface) {
func (def *Definition) annotateWithDynamicUsage(es expreduceapi.EvalStateInterface) {
if len(def.Usage) > 0 {
return
}
Expand All @@ -158,8 +158,8 @@ func (def *Definition) AnnotateWithDynamicUsage(es expreduceapi.EvalStateInterfa
}

func (def *Definition) AnnotateWithDynamic(es expreduceapi.EvalStateInterface) {
def.AnnotateWithDynamicTests(es)
def.AnnotateWithDynamicUsage(es)
def.annotateWithDynamicTests(es)
def.annotateWithDynamicUsage(es)
}

type NamedDefSet struct {
Expand All @@ -173,30 +173,30 @@ func GetAllDefinitions() (defs []NamedDefSet) {
defs = append(defs, NamedDefSet{"comparison", getComparisonDefinitions()})
defs = append(defs, NamedDefSet{"atoms", getAtomsDefinitions()})
defs = append(defs, NamedDefSet{"functional", getFunctionalDefinitions()})
defs = append(defs, NamedDefSet{"expression", GetExpressionDefinitions()})
defs = append(defs, NamedDefSet{"equationdata", GetEquationDataDefinitions()})
defs = append(defs, NamedDefSet{"solve", GetSolveDefinitions()})
defs = append(defs, NamedDefSet{"flowcontrol", GetFlowControlDefinitions()})
defs = append(defs, NamedDefSet{"list", GetListDefinitions()})
defs = append(defs, NamedDefSet{"matrix", GetMatrixDefinitions()})
defs = append(defs, NamedDefSet{"expression", getExpressionDefinitions()})
defs = append(defs, NamedDefSet{"equationdata", getEquationDataDefinitions()})
defs = append(defs, NamedDefSet{"solve", getSolveDefinitions()})
defs = append(defs, NamedDefSet{"flowcontrol", getFlowControlDefinitions()})
defs = append(defs, NamedDefSet{"list", getListDefinitions()})
defs = append(defs, NamedDefSet{"matrix", getMatrixDefinitions()})
defs = append(defs, NamedDefSet{"arithmetic", getArithmeticDefinitions()})
defs = append(defs, NamedDefSet{"specialsyms", getSpecialSymsDefinitions()})
defs = append(defs, NamedDefSet{"power", GetPowerDefinitions()})
defs = append(defs, NamedDefSet{"random", GetRandomDefinitions()})
defs = append(defs, NamedDefSet{"power", getPowerDefinitions()})
defs = append(defs, NamedDefSet{"random", getRandomDefinitions()})
defs = append(defs, NamedDefSet{"replacement", getReplacementDefinitions()})
defs = append(defs, NamedDefSet{"sort", GetSortDefinitions()})
defs = append(defs, NamedDefSet{"system", GetSystemDefinitions()})
defs = append(defs, NamedDefSet{"trig", GetTrigDefinitions()})
defs = append(defs, NamedDefSet{"plot", GetPlotDefinitions()})
defs = append(defs, NamedDefSet{"string", GetStringDefinitions()})
defs = append(defs, NamedDefSet{"time", GetTimeDefinitions()})
defs = append(defs, NamedDefSet{"pattern", GetPatternDefinitions()})
defs = append(defs, NamedDefSet{"boolean", GetBooleanDefinitions()})
defs = append(defs, NamedDefSet{"simplify", GetSimplifyDefinitions()})
defs = append(defs, NamedDefSet{"numbertheory", GetNumberTheoryDefinitions()})
defs = append(defs, NamedDefSet{"stats", GetStatsDefinitions()})
defs = append(defs, NamedDefSet{"manip", GetManipDefinitions()})
defs = append(defs, NamedDefSet{"rubi", GetRubiDefinitions()})
defs = append(defs, NamedDefSet{"sort", getSortDefinitions()})
defs = append(defs, NamedDefSet{"system", getSystemDefinitions()})
defs = append(defs, NamedDefSet{"trig", getTrigDefinitions()})
defs = append(defs, NamedDefSet{"plot", getPlotDefinitions()})
defs = append(defs, NamedDefSet{"string", getStringDefinitions()})
defs = append(defs, NamedDefSet{"time", getTimeDefinitions()})
defs = append(defs, NamedDefSet{"pattern", getPatternDefinitions()})
defs = append(defs, NamedDefSet{"boolean", getBooleanDefinitions()})
defs = append(defs, NamedDefSet{"simplify", getSimplifyDefinitions()})
defs = append(defs, NamedDefSet{"numbertheory", getNumberTheoryDefinitions()})
defs = append(defs, NamedDefSet{"stats", getStatsDefinitions()})
defs = append(defs, NamedDefSet{"manip", getManipDefinitions()})
defs = append(defs, NamedDefSet{"rubi", getRubiDefinitions()})

// Check for duplicate definitions
definedNames := make(map[string]bool)
Expand Down
6 changes: 3 additions & 3 deletions expreduce/builtin_arithmetic.go
Expand Up @@ -118,7 +118,7 @@ func getArithmeticDefinitions() (defs []Definition) {
Name: "Plus",
Default: "0",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfix(this.GetParts()[1:], " + ", "System`Plus", params)
return toStringInfix(this.GetParts()[1:], " + ", "System`Plus", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
// Calls without argument receive identity values
Expand Down Expand Up @@ -171,7 +171,7 @@ func getArithmeticDefinitions() (defs []Definition) {
if params.Form == "TeXForm" {
delim = " "
}
ok, res := ToStringInfix(this.GetParts()[1:], delim, "System`Times", params)
ok, res := toStringInfix(this.GetParts()[1:], delim, "System`Times", params)
if ok && strings.HasPrefix(res, "(-1)"+delim) {
return ok, "-" + res[5:]
}
Expand All @@ -192,7 +192,7 @@ func getArithmeticDefinitions() (defs []Definition) {
res = atoms.NewExpression([]expreduceapi.Ex{atoms.NewSymbol("System`Times")})
rAsInt, rIsInt := realPart.(*atoms.Integer)
if rIsInt && rAsInt.Val.Cmp(big.NewInt(0)) == 0 {
containsInfinity := MemberQ(this.GetParts()[symStart:], atoms.NewExpression([]expreduceapi.Ex{
containsInfinity := memberQ(this.GetParts()[symStart:], atoms.NewExpression([]expreduceapi.Ex{
atoms.NewSymbol("System`Alternatives"),
atoms.NewSymbol("System`Infinity"),
atoms.NewSymbol("System`ComplexInfinity"),
Expand Down
4 changes: 2 additions & 2 deletions expreduce/builtin_atoms.go
Expand Up @@ -51,12 +51,12 @@ func getAtomsDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Im",
OmitDocumentation: true,
ExpreduceSpecific: true,
expreduceSpecific: true,
})
defs = append(defs, Definition{
Name: "Re",
OmitDocumentation: true,
ExpreduceSpecific: true,
expreduceSpecific: true,
})
return
}
6 changes: 3 additions & 3 deletions expreduce/builtin_boolean.go
Expand Up @@ -5,11 +5,11 @@ import (
"github.com/corywalker/expreduce/pkg/expreduceapi"
)

func GetBooleanDefinitions() (defs []Definition) {
func getBooleanDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "And",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfix(this.GetParts()[1:], " && ", "", params)
return toStringInfix(this.GetParts()[1:], " && ", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
res := atoms.NewExpression([]expreduceapi.Ex{atoms.NewSymbol("System`And")})
Expand All @@ -35,7 +35,7 @@ func GetBooleanDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Or",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfix(this.GetParts()[1:], " || ", "", params)
return toStringInfix(this.GetParts()[1:], " || ", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
res := atoms.NewExpression([]expreduceapi.Ex{atoms.NewSymbol("System`Or")})
Expand Down
2 changes: 1 addition & 1 deletion expreduce/builtin_combinatorics.go
Expand Up @@ -19,7 +19,7 @@ func genIntegerPartitions(n int, k int, startAt int, prefix []int, parts *[][]in
*parts = append(*parts, make([]int, len(prefix)))
copy((*parts)[len(*parts)-1], prefix)
} else {
genIntegerPartitions(n-i, k, Min(i, n-i), prefix, parts)
genIntegerPartitions(n-i, k, min(i, n-i), prefix, parts)
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions expreduce/builtin_comparison.go
Expand Up @@ -10,8 +10,8 @@ import (
type extremaFnType int

const (
MaxFn extremaFnType = iota
MinFn
maxFn extremaFnType = iota
minFn
)

func extremaFunction(this expreduceapi.ExpressionInterface, fnType extremaFnType, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
Expand All @@ -30,7 +30,7 @@ func extremaFunction(this expreduceapi.ExpressionInterface, fnType extremaFnType
this.GetParts()[0] = origHead

if len(this.GetParts()) == 1 {
if fnType == MaxFn {
if fnType == maxFn {
return atoms.E(atoms.S("Times"), atoms.NewInt(-1), atoms.S("Infinity"))
} else {
return atoms.S("Infinity")
Expand All @@ -45,7 +45,7 @@ func extremaFunction(this expreduceapi.ExpressionInterface, fnType extremaFnType
break
}
}
if fnType == MaxFn {
if fnType == maxFn {
i -= 1
return atoms.NewExpression(append([]expreduceapi.Ex{this.GetParts()[0]}, this.GetParts()[i:]...))
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Equal",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " == ", "System`Equal", false, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " == ", "System`Equal", false, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) < 1 {
Expand All @@ -103,7 +103,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Unequal",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " != ", "System`Unequal", false, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " != ", "System`Unequal", false, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) != 3 {
Expand All @@ -125,7 +125,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "SameQ",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " === ", "System`SameQ", false, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " === ", "System`SameQ", false, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) < 1 {
Expand All @@ -146,7 +146,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "UnsameQ",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " =!= ", "System`UnsameQ", false, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " =!= ", "System`UnsameQ", false, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) < 1 {
Expand All @@ -170,8 +170,8 @@ func getComparisonDefinitions() (defs []Definition) {
return this
}

_, IsExpr := this.GetParts()[1].(expreduceapi.ExpressionInterface)
if IsExpr {
_, isExpr := this.GetParts()[1].(expreduceapi.ExpressionInterface)
if isExpr {
return atoms.NewSymbol("System`False")
}
return atoms.NewSymbol("System`True")
Expand All @@ -187,7 +187,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Less",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " < ", "", true, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " < ", "", true, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) != 3 {
Expand All @@ -211,7 +211,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Greater",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " > ", "", true, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " > ", "", true, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) != 3 {
Expand All @@ -234,7 +234,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "LessEqual",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " <= ", "", true, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " <= ", "", true, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) != 3 {
Expand All @@ -261,7 +261,7 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "GreaterEqual",
toString: func(this expreduceapi.ExpressionInterface, params expreduceapi.ToStringParams) (bool, string) {
return ToStringInfixAdvanced(this.GetParts()[1:], " >= ", "", true, "", "", params)
return toStringInfixAdvanced(this.GetParts()[1:], " >= ", "", true, "", "", params)
},
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) != 3 {
Expand Down Expand Up @@ -294,13 +294,13 @@ func getComparisonDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Max",
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
return extremaFunction(this, MaxFn, es)
return extremaFunction(this, maxFn, es)
},
})
defs = append(defs, Definition{
Name: "Min",
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
return extremaFunction(this, MinFn, es)
return extremaFunction(this, minFn, es)
},
})
defs = append(defs, Definition{Name: "PossibleZeroQ"})
Expand Down
2 changes: 1 addition & 1 deletion expreduce/builtin_equationdata.go
@@ -1,5 +1,5 @@
package expreduce

func GetEquationDataDefinitions() (defs []Definition) {
func getEquationDataDefinitions() (defs []Definition) {
return
}
36 changes: 18 additions & 18 deletions expreduce/builtin_expression.go
Expand Up @@ -7,15 +7,15 @@ import (
"github.com/corywalker/expreduce/pkg/expreduceapi"
)

func CalcDepth(ex expreduceapi.Ex) int {
func calcDepth(ex expreduceapi.Ex) int {
expr, isExpr := ex.(expreduceapi.ExpressionInterface)
if !isExpr {
return 1
}
theMax := 1
// Find max depth of params. Heads are not counted.
for i := 1; i < len(expr.GetParts()); i++ {
theMax = Max(theMax, CalcDepth(expr.GetParts()[i]))
theMax = max(theMax, calcDepth(expr.GetParts()[i]))
}
return theMax + 1
}
Expand Down Expand Up @@ -45,40 +45,40 @@ func leafCount(e expreduceapi.Ex) int64 {
return 1
}

func GetExpressionDefinitions() (defs []Definition) {
func getExpressionDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "Head",
legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex {
if len(this.GetParts()) != 2 {
return this
}

_, IsFlt := this.GetParts()[1].(*atoms.Flt)
if IsFlt {
_, isFlt := this.GetParts()[1].(*atoms.Flt)
if isFlt {
return atoms.NewSymbol("System`Real")
}
_, IsInteger := this.GetParts()[1].(*atoms.Integer)
if IsInteger {
_, isInteger := this.GetParts()[1].(*atoms.Integer)
if isInteger {
return atoms.NewSymbol("System`Integer")
}
_, IsString := this.GetParts()[1].(*atoms.String)
if IsString {
_, isString := this.GetParts()[1].(*atoms.String)
if isString {
return atoms.NewSymbol("System`String")
}
_, IsSymbol := this.GetParts()[1].(*atoms.Symbol)
if IsSymbol {
_, isSymbol := this.GetParts()[1].(*atoms.Symbol)
if isSymbol {
return atoms.NewSymbol("System`Symbol")
}
_, IsRational := this.GetParts()[1].(*atoms.Rational)
if IsRational {
_, isRational := this.GetParts()[1].(*atoms.Rational)
if isRational {
return atoms.NewSymbol("System`Rational")
}
_, IsComplex := this.GetParts()[1].(*atoms.Complex)
if IsComplex {
_, isComplex := this.GetParts()[1].(*atoms.Complex)
if isComplex {
return atoms.NewSymbol("System`Complex")
}
asExpr, IsExpression := this.GetParts()[1].(expreduceapi.ExpressionInterface)
if IsExpression {
asExpr, isExpression := this.GetParts()[1].(expreduceapi.ExpressionInterface)
if isExpression {
return asExpr.GetParts()[0]
}
return this
Expand All @@ -90,7 +90,7 @@ func GetExpressionDefinitions() (defs []Definition) {
if len(this.GetParts()) != 2 {
return this
}
return atoms.NewInteger(big.NewInt(int64(CalcDepth(this.GetParts()[1]))))
return atoms.NewInteger(big.NewInt(int64(calcDepth(this.GetParts()[1]))))
},
})
defs = append(defs, Definition{
Expand Down
2 changes: 1 addition & 1 deletion expreduce/builtin_flowcontrol.go
Expand Up @@ -48,7 +48,7 @@ func isBreak(e expreduceapi.Ex) bool {
return isBr
}

func GetFlowControlDefinitions() (defs []Definition) {
func getFlowControlDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "If",
// WARNING: Watch out for putting rules here. It can interfere with how
Expand Down

0 comments on commit c8107f1

Please sign in to comment.