YAPC::EU 2018 Glasgow Update!

This commit is contained in:
Ingy döt Net 2018-08-17 15:15:24 +01:00
parent 22f33d4004
commit 4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions

View file

@ -1,11 +1,27 @@
import Data.List (transpose)
import Data.List (intercalate, transpose)
import Control.Monad (join)
spiral :: Int -> Int -> Int -> [[Int]]
spiral rows cols start =
if rows > 0
then [start .. start + cols - 1] :
(reverse <$> transpose (spiral cols (rows - 1) (start + cols)))
else [[]]
spiral :: Int -> [[Int]]
spiral n = go n n 0
where
go rows cols start =
if 0 < rows
then [start .. start + pred cols] :
fmap reverse (transpose $ go cols (pred rows) (start + cols))
else [[]]
main :: IO ()
main = mapM_ print $ spiral 5 5 0
main = putStrLn $ wikiTable (spiral 5)
-- TABLE FORMATTING ----------------------------------------
wikiTable :: Show a => [[a]] -> String
wikiTable =
join .
("{| class=\"wikitable\" style=\"text-align:center;" :) .
("width:12em;height:12em;table-layout:fixed;\"\n|-\n" :) .
return .
(++ "\n|}") .
intercalate "\n|-\n" .
fmap (('|' :) . (' ' :) . intercalate " || " . fmap show)