Skip to content

Instantly share code, notes, and snippets.

@modalsoul
Created March 13, 2014 00:35
Show Gist options
  • Select an option

  • Save modalsoul/9519683 to your computer and use it in GitHub Desktop.

Select an option

Save modalsoul/9519683 to your computer and use it in GitHub Desktop.
object Catalan {
def myCatalan(m:Int, n:Int, accum:Int):Int = {
(m>0 && n>0, m==n) match {
case (false, _) => accum
case (_, true) => myCatalan(m, n-1, accum + 1)
case (_, false) => myCatalan(m-1, n, accum + 1)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment