1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package main type Stack []float64 func (s *Stack) push(v float64) { *s = append(*s, v) } func (s *Stack) pop() *float64 { if len(*s) > 0 { v := (*s)[len(*s)-1] *s = (*s)[:len(*s)-1] return &v } return nil }