Created
March 24, 2021 18:11
-
-
Save sonumehrotra/8b8d6262735b25046eb26f67139abecd to your computer and use it in GitHub Desktop.
This file contains 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
enum MyList[+T]: | |
case Cons(head: T, tail: MyList[T]) | |
case EmptyList | |
def isEmpty: Boolean = this match { | |
case Cons(_, _) => false | |
case EmptyList => true | |
} | |
def prepend[R >: T](element: R): MyList[R] = Cons(element, this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment