An important point to know about this solution is that if you square an integer, the result will actually be a Double, so you'll need to convert it back to an Int or a Long, if you want those types.
More Scala power multipliers
Collection
[
|
...
]