Is there an idiom to use a val in a computation twice, without having to create a new intermediate val?
That is, if map() somehow worked on non-collections, it would be nice to be able to do:
3.map(x => Math.pow(x,x))
The closest I’ve come to on my own is:
List(3).map(x => Math.pow(x,x)).apply(0)