如何使序列将数字提升为幂序列

How to make sequence raising a number to a sequence of powers

我有:

cost = c(2^(-5),2^(-3),2^(-1),2^(1),2^(3),2^(5),2^(7),2^(9),2^(11),2^(13),2^(15))

我想要一个更优雅的命令,例如:

seq(from = 2^(-5), to = 2^(15), by = __)

^ 在两个参数中都被矢量化了,所以你可以将 2 提高到你很好的线性幂序列:

2^seq(from = -5, to = 15, by = 2)