-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hmath.go
73 lines (66 loc) · 1.34 KB
/
Hmath.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package hmath
type MathFunc interface {
//MathArray
Get(MathContext)(float64, error) // Solving
//GetDerivative()MathFunc
//GetAntiderivative()MathFunc
//Simplifying()
String()string // Printing
NeededValues()(MathComponents, error) // Testin by all mc.Get("X") for solving
ErrorTest()error
}
func MathFuncPrint(a ...MathFunc)(ret []string){
for i := range a {
ret = append(ret, a[i].String())
}
return
}
// Single math object body is array of mathematical object
/*
type MathArray interface {
GetBody()(bool, []MathFunc)
//Types()MathTypeId
}
*/
type names struct{
name string
value MathFunc
}
func(n names)String()string{
return "F("+n.name+") = " + n.value.String()
}
func Name(str string, value MathFunc)names{
return names{
name : str,
value : value,
}
}
type MathComponents map[string]struct{}
func(mv MathComponents)String()(ret string){
ret += "["
for i,_ := range mv {
ret += i + ", "
}
if len(mv) > 0 {
ret = ret[:len(ret)-len(", ")]
}else{
ret += "No needed values"
}
ret += "]"
return
}
func(mv MathComponents)Add(ellements ...MathComponents)(ret MathComponents){
ret = make(MathComponents)
for i,_ := range mv{
ret[i] = struct{}{}
}
for i,_ := range ellements{
for e,_ := range ellements[i]{
ret[e] = struct{}{}
}
}
return
}
func mvNew(str string)MathComponents{
return MathComponents{str:struct{}{}}
}