Implement a minimal `Option` that has `map` and `flatMap`. ```scala import scala.{Option => _} // implement here sealed trait Option[+A] { def map[B](f: A => B): Option[B] def flatMap[B](ff: A => F[B]): Option[B] def fold[C](c: => C)(f: A => C): Option[C] } case class Some[+A](value: A) extends Option[A] { def map[B](f: A => B): Option[B] = { Some(f(value)) } def flatMap[B](ff: A => Option[B]): Option[B] = { ff(value) } def fold[C](c: => C)(f: A => C): Option[C] = { map(f) } } case object None extends Option[Nothing] { def map[B](f: A => B): Option[B] = None def flatMap[B](ff: A => B): Option[B] = None def fold[C](c: => C)(f: A => C): Option[C] = { Some(c) } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up