This commit is contained in:
parent
d573528f3b
commit
bfb8a2b0d8
13
list/list.go
13
list/list.go
@ -35,17 +35,22 @@ func Empty() IList {
|
|||||||
|
|
||||||
var emptyList = Empty()
|
var emptyList = Empty()
|
||||||
|
|
||||||
func New(val any) *List {
|
func New(val any) IList {
|
||||||
this := new(List)
|
this := new(List)
|
||||||
this.Value = val
|
this.Value = val
|
||||||
this.next = emptyList
|
this.next = emptyList
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Cons(val any, rest IList) IList {
|
||||||
|
this := new(List)
|
||||||
|
this.Value = val
|
||||||
|
this.next = rest
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
func (this *List) Conj(val any) IList {
|
func (this *List) Conj(val any) IList {
|
||||||
new_head := New(val)
|
return Cons(val, this)
|
||||||
new_head.next = this
|
|
||||||
return new_head
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user