Open mchirico opened 3 years ago
mchirico, Thanks for opening this issue!
package main
import "fmt"
type Node struct { prev Node next Node key interface{} }
type List struct { head Node tail Node }
func (L *List) Insert(key interface{}) { list := &Node{ next: L.head, key: key, } if L.head != nil { L.head.prev = list } L.head = list
l := L.head
for l.next != nil {
l = l.next
}
L.tail = l
}
func (l *List) Display() { list := l.head for list != nil { fmt.Printf("%+v ->", list.key) list = list.next } fmt.Println() }
func Display(list *Node) { for list != nil { fmt.Printf("%v ->", list.key) list = list.next } fmt.Println() }
func main() { link := List{} link.Insert("Bagels") link.Insert("Salad") link.Insert("Chocolate") link.Insert("Chicken") link.Insert("Broccoli") link.Insert("Cabbage")
fmt.Printf("Grocery List: %v\n", link.head.key)
link.Display()
}
Create a Go program with 3 or more of the past daily items. Create it quickly, putting down what comes to mind... it doesn't have to make sense...