feat: indenter

This commit is contained in:
2022-04-26 19:19:42 +02:00
parent adfd4238f7
commit c1aaeb4339

15
indenter/indenter.hs Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env runhaskell
import Control.Monad
import Data.Maybe
import System.Environment
import System.Random
import Text.Read
main :: IO ()
main = do
intArgument <- (readMaybe <=< listToMaybe) <$> getArgs
let choice xs = (xs !!) <$> randomRIO (0, length xs - 1)
sample population = flip replicateM (choice population) =<< randomRIO (1, fromMaybe 5 intArgument)
randomWhitespace = sample " \t\n"
inputWords <- words <$> getContents
putStrLn . concat =<< mapM (\x -> (x++) <$> randomWhitespace) inputWords