Skip to content

Instantly share code, notes, and snippets.

@ruurtjan
Created May 22, 2020 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruurtjan/c9ce260cc1b3ef7b65b3d5815aee21d8 to your computer and use it in GitHub Desktop.
Save ruurtjan/c9ce260cc1b3ef7b65b3d5815aee21d8 to your computer and use it in GitHub Desktop.
functional-dsl-blog-5.scala
object Original {
def flatMap[A, B](l: List[A], f: A => List[B]): List[B] = ???
def flatten[A](l: List[List[A]]): List[A] =
Original.flatMap(l, (as: List[A]) => as)
def map[A, B](l: List[A], f: A => B): List[B] =
Original.flatMap(l, List(_))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment