Created
January 31, 2012 06:44
-
-
Save jordanlewis/1709271 to your computer and use it in GitHub Desktop.
PFDS ListStack
This file contains hidden or 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
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