summaryrefslogtreecommitdiff
path: root/test/pos/cours2a.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/pos/cours2a.scala')
-rw-r--r--test/pos/cours2a.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/pos/cours2a.scala b/test/pos/cours2a.scala
new file mode 100644
index 0000000000..b888b88a96
--- /dev/null
+++ b/test/pos/cours2a.scala
@@ -0,0 +1,16 @@
+module m1 {
+ def factorial(n: Int): Int =
+ if (n == 0) 1
+ else n * factorial(n-1);
+}
+
+module m2 {
+
+ def factorial(n: Int): Int = {
+ def factIter(n: Int, acc: Int): Int = {
+ if (n == 0) acc
+ else factIter(n - 1, acc * n)
+ }
+ factIter(n, 1)
+ }
+}