September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,20 +1,27 @@
#!/usr/bin/runhaskell
import Data.List (unfoldr)
import Control.Monad (forM_)
import System.Random
import Data.List as L
import Text.Blaze.Html5
import Text.Blaze.Html.Renderer.Pretty
import qualified Text.Blaze.Html5 as B
import Text.Blaze.Html.Renderer.Pretty (renderHtml)
makeTable :: RandomGen g => [String] -> Int -> g -> Html
import System.Random (RandomGen, getStdGen, randomRs, split)
makeTable
:: RandomGen g
=> [String] -> Int -> g -> B.Html
makeTable headings nRows gen =
table $ do
thead $ tr $ forM_ (L.map toHtml headings) th
tbody $ forM_ (zip [1 .. nRows] $ unfoldr (Just . split) gen)
(\(x,g) -> tr $ forM_ (take (length headings)
(x:randomRs (1000,9999) g)) (td . toHtml))
B.table $
do B.thead $ B.tr $ forM_ (B.toHtml <$> headings) B.th
B.tbody $
forM_
(zip [1 .. nRows] $ unfoldr (Just . split) gen)
(\(x, g) ->
B.tr $
forM_
(take (length headings) (x : randomRs (1000, 9999) g))
(B.td . B.toHtml))
main :: IO ()
main = do
g <- getStdGen
putStrLn $ renderHtml $ makeTable ["", "X", "Y", "Z"] 3 g