Created
March 22, 2023 05:35
-
-
Save lotusirous/6872c139a60446ea63113d01908e48fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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