RosettaCodeData/Task/Determinant-and-permanent/Factor/determinant-and-permanent.factor
2023-07-01 13:44:08 -04:00

6 lines
251 B
Factor

USING: fry kernel math.combinatorics math.matrices sequences ;
: permanent ( matrix -- x )
dup square-matrix? [ "Matrix must be square." throw ] unless
[ dim first <iota> ] keep
'[ [ _ nth nth ] map-index product ] map-permutations sum ;