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()
|
||||
|
||||
func New(val any) *List {
|
||||
func New(val any) IList {
|
||||
this := new(List)
|
||||
this.Value = val
|
||||
this.next = emptyList
|
||||
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 {
|
||||
new_head := New(val)
|
||||
new_head.next = this
|
||||
return new_head
|
||||
return Cons(val, this)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user