Q:

Vector as an exponent in Julia

I have very basic question. I am new to Julia and used to code in R a lot. I need to take a scalar to the multiple powers, represented by a vector: 3^[2,3]. I got an error "Method error: no method matching ^...". I tried 3^Array([2,3]), but got the error again. At the same time, 3*[2,3] works as expected. Is there any way to do it in Julia without using for loop?

A:

I think you are looking for the . or broadcast functions that allow you to apply any other functions elementwise!
3 .^ [2,3] or broadcast(^, 3, [2,3])

