package main
import (
"fmt"
)
func main() {
var list *LinkedList
list = &LinkedList{}
list.Head = &Node{Value : 4}
list.Head.Next = &Node{Value : 2}
list.Head.Next.Next = &Node{Value : 3}
list.Head.Next.Next.Next = &Node{Value : 1}
fmt.Println(list.printValues())
}
type Node struct{
Value rune
Next *Node
}
func (n *Node) getNext() *Node{
return n.Next;
}
type LinkedList struct{
Head *Node
}
func (list *LinkedList) printValues() string {
curr := list.Head
str := ""
for curr != nil{
str += fmt.Sprintln(curr.Value)
curr = curr.Next
}
return str
}