Is there a clean idiom for evaluating a sequence of computations and “taking” the final one?
In my case I’m doing some profiling and I do several steps to warmup and I want the last one.
The code looks sort of like the following (very simplified)
for{i <- 1 to n}{
f(i)
do_some_stuff
do_some_more_stuff
g(i)
}
I would like this to evaluate to the final call to g(i)
. I can of course do it in an ugly way by assign tmp = g(i)
each time and then just returning tmp
, but is there a more elegant way?