equal
deleted
inserted
replaced
5 // polymorphic types |
5 // polymorphic types |
6 // implicits |
6 // implicits |
7 |
7 |
8 import scala.annotation.tailrec |
8 import scala.annotation.tailrec |
9 |
9 |
10 @tailrec |
|
11 def fact(n: BigInt): BigInt = |
10 def fact(n: BigInt): BigInt = |
12 if (n == 0) 1 else n * fact(n - 1) |
11 if (n == 0) 1 else n * fact(n - 1) |
13 |
12 |
14 @tailrec |
13 |
15 def factT(n: BigInt, acc: BigInt): BigInt = |
14 def factT(n: BigInt, acc: BigInt): BigInt = |
16 if (n == 0) acc else factT(n - 1, n * acc) |
15 if (n == 0) acc else factT(n - 1, n * acc) |
17 |
16 |
18 |
17 |
19 println(factT(1000000), 1)) |
18 println(factT(1000000), 1)) |
20 |
19 |
21 |
20 |
22 def foo[A](args: List[A]) = ??? |
21 def foo[A](args: List[A]) = ??? |
23 |
22 |
24 foo(List("1","2","3","4")) |
23 foo(List("1","2","3","4")) |
25 import scala.annotation.tailrec |
|
26 |
24 |
27 |
25 |
28 // from knight1.scala |
26 // from knight1.scala |
29 def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ??? |
27 def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ??? |
30 |
28 |