Skip to content

Instantly share code, notes, and snippets.

View maiorovi's full-sized avatar

Yehor Maiorov maiorovi

View GitHub Profile
import scala.annotation.tailrec
trait LinkedList[+T] {
final def foreach(f: T => Unit): Unit = {
this match {
case Node(head, tail) => {
f(head);
tail.foreach(f)
}