Spiral matrix: Difference between revisions

m
→‎{{header|Factor}}: grade, not rank!
m (→‎{{header|Factor}}: formatting)
m (→‎{{header|Factor}}: grade, not rank!)
Line 1,443:
 
=={{header|Factor}}==
This is an implementation of Joey Tuttle's method for computing a spiral directly as a list and then reshaping it into a matrix, as described in the [http://rosettacode.org/wiki/Spiral_matrix#J J entry]. To summarize, we construct a list with <code>n*n</code> elements by following some simple rules, then take its cumulative sum, and finally its inverse permutation (or rankgrade in J parlance). This gives us a list which can be reshaped to the final matrix.
<lang factor>USING: arrays grouping io kernel math math.combinatorics
math.ranges math.statistics prettyprint sequences
1,808

edits