Example #1
0
func ExampleLoop() {
	s := stack.EmptyStack()
	for i := 1; i < 6; i++ {
		s.Push(i)
	}
	sum := 0
	for !s.Empty() {
		var val int = s.Pop().(int)
		sum += val
	}
	fmt.Println(sum)
	// Output: 15
}
Example #2
0
func Example() {
	s := stack.EmptyStack()
	s.Push(0)
	s.Push(1)
	s.Push(2)

	first := s.Pop()
	second := s.Pop()
	third := s.Pop()

	fmt.Println(first, second, third)
	// Output: 2 1 0
}