Closed albrow closed 6 years ago
I think I have a similar example. Hope it helps. Here is the code:
package main
func main() {
lli := &LinkedList[int]
lli.InsertFirst[int](1)
}
type Node[T] struct {
data T
next *Node[T]
prev *Node[T]
}
type LinkedList[T] struct {
head *Node[T]
tail *Node[T]
}
func (list *LinkedList[T]) InsertFirst(i T) {
data := &Node[T]{data: i}
if list.head != nil {
list.head.prev = data
data.next = list.head
}
list.head = data
}
This is fixed in 02a4bdb70ec696af52a10d8bc71cb8ad6fa45dd3. I also added a linked list implementation which uses recursive generic types to the examples/ directory.
This is copied over from #3 since it is a separate issue.