RosettaCodeData/Task/Matrix-exponentiation-operator/Factor/matrix-exponentiation-operator.factor
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

7 lines
205 B
Factor

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 ;