RosettaCodeData/Task/Determinant-and-permanent/Factor/determinant-and-permanent.factor

7 lines
251 B
Factor
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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 ;