def sumInts(a: Int, b: Int): Double = if (a > b) 0 else a + sumInts(a + 1, b) def sumCubes(a: Int, b: Int): Double = if (a > b) 0 else a * a * a + sumCubes(a + 1, b) def sumRec(a: Int, b: Int): Double = if (a > b) 0 else 1.0 / a + sumRec(a + 1, b) def mapReduce(f: Int => Double, a: Int, b: Int): Double = if (a > b) 0 else f(a) + mapReduce(f, a + 1, b) sumInts(3, 5) sumCubes(1, 3) sumRec(1, 3) mapReduce(i => i, 3, 5) mapReduce(i => i*i*i, 1, 3) mapReduce(i => 1.0/i, 1, 3)