Last active
February 23, 2017 01:58
-
-
Save patrickt/552d41a0166d75add6b39313d72cf473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack --resolver=lts-8.2 runghc --package text | |
{-# LANGUAGE OverloadedStrings #-} | |
-- example usage: | |
-- $ clapper "I wrote this to troll @peterb" | |
-- yields | |
-- I π wrote π this π to π troll π peterb π | |
import Data.List (intersperse) | |
import qualified Data.Text as Text | |
import qualified Data.Text.IO as Text | |
import Control.Monad | |
import System.Environment | |
import System.Exit | |
main :: IO () | |
main = do | |
args <- fmap Text.pack <$> getArgs | |
when (length args == 0) (die "Usage: clapper [SEPARATOR] STRING") | |
let (separator, message) = | |
if length args >= 2 | |
then (args !! 0, args !! 1) | |
else ("π", args !! 0) | |
let asWords = Text.words message | |
punctuated = intersperse separator asWords ++ [separator] | |
glued = Text.unwords punctuated | |
Text.putStrLn glued |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are the Blighttown beneath my Dark Souls game.