In R, this code: c(1,2,3)^2 yields 1, 4, 9 and 2^c(1,2,3) yields 2, 4, 8.
Is there a syntactically nice way to combine these two? That is operation(c(1,2,3), c(0, 1, 2), which would give [1, 1, 1], [1, 2, 3], [1, 4, 9]?
In other words, I'd like to raise the first array to all values from the second array.
Is it even possible without resolving to for loops?