Timing Project Euler Problem 1
So, I pasted your code into my IDE and ran it in the debugger, and there isn't really any way to do exactly what you want to do. The function object doesn't appear to have any knowledge of anything other than how to call it.

Your best bet seems to be to modify the timing function to something like this:

  def time[R](f: =&gt; R, name: String): Unit = {
    val t0 = System.nanoTime()
    val r = f
    val t1 = System.nanoTime()

    val t = (t1-t0)/1000

    println(s"The result of $name is: $r time taken $t ms ")
  }


And then your call would be something like this:

   time (func, "func")


In a larger app, if you needed to pass around functions with their name, you could create a small object such as:

class Caller[R](f: =&gt; R, name: String) {
  def time(): Unit = {
    val t0 = System.nanoTime()
    val r = f
    val t1 = System.nanoTime()

    val t = (t1-t0)/1000

    println(s"The result of $name is: $r time taken $t ms ")
  }
}


Create it like so:

val a = new Caller(func, "func")


And call it like so:

a.time()