Spiral matrix: Difference between revisions

m
→‎{{header|Haskell}}: (tidying - switched if to guards)
m (→‎{{header|Haskell}}: (tidying - switched if to guards))
Line 1,884:
spiral n = go n n 0
where
go rows cols start =x
if| 0 < rows =
then [startx .. startpred cols + pred colsx] :
fmap reverse (transpose $ go cols (pred rows) (startx + cols))
| otherwise else= [[]]
 
main :: IO ()
main = putStrLn $ wikiTable (spiral 5)
 
 
Line 1,899 ⟶ 1,896:
wikiTable =
join .
("{| class=\"wikitable\" style=\"text-align:center right;" :) .
("width:12em;height:12em;table-layout:fixed;\"\n|-\n" :) .
return .
Line 1,906 ⟶ 1,903:
fmap (('|' :) . (' ' :) . intercalate " || " . fmap show)</lang>
{{Out}}
{| class="wikitable" style="text-align:center right;width:12em;height:12em;table-layout:fixed;"|-
| 0 || 1 || 2 || 3 || 4
|-
9,655

edits