init reader for lists
This commit is contained in:
@@ -29,6 +29,9 @@ func (this *List) Conj(val any) *List {
|
||||
}
|
||||
|
||||
func Conj(this *List, val any) *List {
|
||||
if this == nil {
|
||||
return New(val)
|
||||
}
|
||||
new_head := New(val)
|
||||
new_head.next = this
|
||||
return new_head
|
||||
@@ -46,6 +49,9 @@ func (this *List) Rest() *List {
|
||||
}
|
||||
|
||||
func First(this *List) any {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return this.Value
|
||||
}
|
||||
|
||||
@@ -53,6 +59,10 @@ func (this *List) First() any {
|
||||
return First(this)
|
||||
}
|
||||
|
||||
func IsEmpty(this *List) bool {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
func String(this *List) string {
|
||||
if this == nil {
|
||||
return "{}"
|
||||
|
||||
Reference in New Issue
Block a user