RosettaCodeData/Task/Matrix-exponentiation-operator/Factor/matrix-exponentiation-operator.factor

8 lines
205 B
Factor
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
USING: kernel math math.matrices sequences ;
: my-m^n ( m n -- m' )
dup 0 < [ "no negative exponents" throw ] [
[ drop length identity-matrix ]
[ swap '[ _ m. ] times ] 2bi
] if ;