Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Created July 19, 2018 14:57
Show Gist options
  • Save luojiyin1987/0f315799c13f7f13102f9f8c536ccd92 to your computer and use it in GitHub Desktop.
Save luojiyin1987/0f315799c13f7f13102f9f8c536ccd92 to your computer and use it in GitHub Desktop.
#golang #stack
type stack []rune
func (s *stack) push(b rune) {
*s = append(*s, b)
}
func (s *stack) pop() (rune, bool) {
if len(*s) > 0 {
res := (*s)[len(*s)-1]
*s = (*s)[:len(*s)-1]
return res, true
}
return 0, false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment