Last updated 6 years ago
Was this helpful?
This one's as straightforward as it gets. List i.e. an immutable linked list is precisely a stack
List
Operation
Complexity
Push
Pop
object Stack { def push[A](as: List[A], a: A): List[A] = a :: as def pop[A](as: List[A]): (Option[A], List[A]) = as.headOption -> as.tail }