Skip to content

Instantly share code, notes, and snippets.

// Stack in Go
package main
import "fmt"
type stack []int
func (s stack) Empty() bool { return len(s) == 0 }
func (s stack) Peek() int { return s[len(s)-1] }
func (s *stack) Put(i int) { *s = append(*s, i) }