Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created March 22, 2023 05:35
Show Gist options
  • Save lotusirous/6872c139a60446ea63113d01908e48fc to your computer and use it in GitHub Desktop.
Save lotusirous/6872c139a60446ea63113d01908e48fc to your computer and use it in GitHub Desktop.
type stack []rune
func (s *stack) push(n rune) {
*s = append(*s, n)
}
func (s *stack) pop() rune {
if s.empty() {
panic("stack is empty")
}
n := len(*s) - 1
v := (*s)[n]
*s = (*s)[:n]
return v
}
func (s *stack) empty() bool {
return len(*s) == 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment