Skip to content

Instantly share code, notes, and snippets.

@jordanlewis
Created January 31, 2012 06:44
Show Gist options
  • Save jordanlewis/1709271 to your computer and use it in GitHub Desktop.
Save jordanlewis/1709271 to your computer and use it in GitHub Desktop.
PFDS ListStack
object ListStack {
def apply[T] : ListStack[T] = new ListStack[T](List())
}
class ListStack[T] private (val l: List[T]) extends Stack[T] {
def isEmpty = l.isEmpty
def cons[U >: T](x: U) = new ListStack(x::l)
def head = l.head
def tail = new ListStack(l.tail)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment