# HG changeset patch # User Christian Urban # Date 1485364980 0 # Node ID 22233a7c32d8bbe0da3264a0434f61ea8a64b461 # Parent fae9db0d979325e11e8a9d868642252ea4ff08bb updated diff -r fae9db0d9793 -r 22233a7c32d8 progs/re2_sol.scala --- a/progs/re2_sol.scala Wed Jan 25 14:51:09 2017 +0000 +++ b/progs/re2_sol.scala Wed Jan 25 17:23:00 2017 +0000 @@ -157,15 +157,10 @@ //non-tail recursive iter -def iter[A](n: Int, f: A => A, x: A): A = - if (n == 0) x else f(iter(n - 1,f, x)) +//def iter[A](n: Int, f: A => A)(x: A): A = +// if (n == 0) x else f(iter(n - 1,f, x)) -iter(200000, (x: Int) => x + 1, 0) -iterT(200000, (x: Int) => x + 1, 0) -iterT(100, (x: Int) => x * 2, 2) -iterT(100, (x: BigInt) => x * 2, BigInt(2)) -iterT(10, (x: String) => x ++ "a", "a") // (2b) @@ -192,8 +187,6 @@ if (fx == x) x else fixpT(f, fx) } -fixpT((x:Int) => if (200000 < x) x else x + 1, 0) - def ctest(n: Long): Long = if (n == 1) 1 else if (n % 2 == 0) n / 2 else 3 * n + 1