style: no "this" or "self" as receiver
This commit is contained in:
@@ -12,12 +12,12 @@ type Abstraction struct {
|
||||
Body Expression
|
||||
}
|
||||
|
||||
func (this *Abstraction) Copy() Expression {
|
||||
return NewAbstraction(this.Parameter, this.Body.Copy())
|
||||
func (a *Abstraction) Copy() Expression {
|
||||
return NewAbstraction(a.Parameter, a.Body.Copy())
|
||||
}
|
||||
|
||||
func (this *Abstraction) Accept(v Visitor) {
|
||||
v.VisitAbstraction(this)
|
||||
func (a *Abstraction) Accept(v Visitor) {
|
||||
v.VisitAbstraction(a)
|
||||
}
|
||||
|
||||
func NewAbstraction(parameter string, body Expression) *Abstraction {
|
||||
@@ -31,12 +31,12 @@ type Application struct {
|
||||
Argument Expression
|
||||
}
|
||||
|
||||
func (this *Application) Copy() Expression {
|
||||
return NewApplication(this.Abstraction.Copy(), this.Argument.Copy())
|
||||
func (a *Application) Copy() Expression {
|
||||
return NewApplication(a.Abstraction.Copy(), a.Argument.Copy())
|
||||
}
|
||||
|
||||
func (this *Application) Accept(v Visitor) {
|
||||
v.VisitApplication(this)
|
||||
func (a *Application) Accept(v Visitor) {
|
||||
v.VisitApplication(a)
|
||||
}
|
||||
|
||||
func NewApplication(function Expression, argument Expression) *Application {
|
||||
@@ -49,12 +49,12 @@ type Variable struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
func (this *Variable) Copy() Expression {
|
||||
return NewVariable(this.Value)
|
||||
func (v *Variable) Copy() Expression {
|
||||
return NewVariable(v.Value)
|
||||
}
|
||||
|
||||
func (this *Variable) Accept(v Visitor) {
|
||||
v.VisitVariable(this)
|
||||
func (v *Variable) Accept(visitor Visitor) {
|
||||
visitor.VisitVariable(v)
|
||||
}
|
||||
|
||||
func NewVariable(name string) *Variable {
|
||||
|
||||
@@ -6,23 +6,23 @@ type stringifyVisitor struct {
|
||||
builder strings.Builder
|
||||
}
|
||||
|
||||
func (this *stringifyVisitor) VisitVariable(a *Variable) {
|
||||
this.builder.WriteString(a.Value)
|
||||
func (v *stringifyVisitor) VisitVariable(a *Variable) {
|
||||
v.builder.WriteString(a.Value)
|
||||
}
|
||||
|
||||
func (this *stringifyVisitor) VisitAbstraction(f *Abstraction) {
|
||||
this.builder.WriteRune('\\')
|
||||
this.builder.WriteString(f.Parameter)
|
||||
this.builder.WriteRune('.')
|
||||
f.Body.Accept(this)
|
||||
func (v *stringifyVisitor) VisitAbstraction(f *Abstraction) {
|
||||
v.builder.WriteRune('\\')
|
||||
v.builder.WriteString(f.Parameter)
|
||||
v.builder.WriteRune('.')
|
||||
f.Body.Accept(v)
|
||||
}
|
||||
|
||||
func (this *stringifyVisitor) VisitApplication(c *Application) {
|
||||
this.builder.WriteRune('(')
|
||||
c.Abstraction.Accept(this)
|
||||
this.builder.WriteRune(' ')
|
||||
c.Argument.Accept(this)
|
||||
this.builder.WriteRune(')')
|
||||
func (v *stringifyVisitor) VisitApplication(c *Application) {
|
||||
v.builder.WriteRune('(')
|
||||
c.Abstraction.Accept(v)
|
||||
v.builder.WriteRune(' ')
|
||||
c.Argument.Accept(v)
|
||||
v.builder.WriteRune(')')
|
||||
}
|
||||
|
||||
func Stringify(e Expression) string {
|
||||
|
||||
@@ -2,32 +2,32 @@ package set
|
||||
|
||||
type Set[T comparable] map[T]bool
|
||||
|
||||
func (this *Set[T]) Add(items ...T) {
|
||||
func (s *Set[T]) Add(items ...T) {
|
||||
for _, item := range items {
|
||||
(*this)[item] = true
|
||||
(*s)[item] = true
|
||||
}
|
||||
}
|
||||
|
||||
func (this Set[T]) Has(item T) bool {
|
||||
return this[item] == true
|
||||
func (s Set[T]) Has(item T) bool {
|
||||
return s[item] == true
|
||||
}
|
||||
|
||||
func (this *Set[T]) Remove(items ...T) {
|
||||
func (s *Set[T]) Remove(items ...T) {
|
||||
for _, item := range items {
|
||||
delete(*this, item)
|
||||
delete(*s, item)
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Set[T]) Union(o Set[T]) {
|
||||
func (s *Set[T]) Union(o Set[T]) {
|
||||
for item := range o {
|
||||
this.Add(item)
|
||||
s.Add(item)
|
||||
}
|
||||
}
|
||||
|
||||
func (this Set[T]) ToList() []T {
|
||||
func (s Set[T]) ToList() []T {
|
||||
list := []T{}
|
||||
|
||||
for item := range this {
|
||||
for item := range s {
|
||||
list = append(list, item)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user