Created
September 14, 2009 09:22
-
-
Save NicolasT/186571 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def fact(x: Int): Int = fact(x, 1) | |
def fact(x: Int, acc: Int): Int = x match { | |
case 0 => acc; | |
case n => fact(n - 1, x * acc) | |
} | |
val facts = (0 to 10).toList.map(fact) | |
println("Facts: " + facts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment