RosettaCodeData/Task/Exponentiation-operator/Brat/exponentiation-operator.brat

14 lines
220 B
Text
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
#Procedure
exp = { base, exp |
1.to(exp).reduce 1, { m, n | m = m * base }
}
#Numbers are weird
1.parent.^ = { rhs |
num = my
1.to(rhs).reduce 1 { m, n | m = m * num }
}
p exp 2 5 #Prints 32
p 2 ^ 5 #Prints 32