RosettaCodeData/Task/Exponentiation-operator/R/exponentiation-operator.r
Ingy döt Net 764da6cbbb CDE
2013-04-10 16:57:12 -07:00

12 lines
181 B
R

# Method
pow <- function(x, y)
{
x <- as.numeric(x)
y <- as.integer(y)
prod(rep(x, y))
}
#Operator
"%pow%" <- function(x,y) pow(x,y)
pow(3, 4) # 81
2.5 %pow% 2 # 6.25