Skip to content

Instantly share code, notes, and snippets.

@LeifWarner
Last active December 17, 2015 20:09
Show Gist options
  • Save LeifWarner/5665795 to your computer and use it in GitHub Desktop.
Save LeifWarner/5665795 to your computer and use it in GitHub Desktop.
// defined on List[A], theoretically
def filterM[M](p: A=>M[A]): M[A] = for {
flg <- p(this.head)
ys <- this.tail.filterM(p)
} yield if (flg) this.head :: ys else ys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment