3 // Stack is a simple implementation of a LIFO stack
9 // An Element which is stored in the Stack
11 value interface{} // All types satisfy the empty interface, so we can store anything here.
15 // Len returns the stack's length
16 func (s *Stack) Len() int {
20 // Push a new element onto the stack
21 func (s *Stack) Push(value interface{}) {
22 s.top = &Element{value, s.top}
26 // Pop removes the top element from the stack and returns its value
27 // If the stack is empty, return nil
28 func (s *Stack) Pop() (value interface{}) {
30 value, s.top = s.top.value, s.top.next
37 // Peek returns the top element of the stack without removing it
38 func (s *Stack) Peek() interface{} {