Skip to content

Instantly share code, notes, and snippets.

@Nucleareal
Last active August 29, 2015 13:56
Show Gist options
  • Save Nucleareal/9345313 to your computer and use it in GitHub Desktop.
Save Nucleareal/9345313 to your computer and use it in GitHub Desktop.
不必要に長いbbop
import System.Random
import Control.Monad
bs :: String
bs = "firstspring1845"
bs' :: String
bs' = "fsrg84"
list :: [Int]
list = [1, 2, 4, 5, 6, 8, 9, 11, 14]
bbop :: RandomGen g => Int -> g -> String
bbop n gen = take n . fmap (\x -> bs' !! x) $ randomRs (0, length bs' -1) gen
bbfold :: Int -> String -> String
bbfold (-1) _ = []
bbfold x str = reverse $ (if elem x list then bs !! x else str !! x) : (bbfold (x-1) str)
main = do
gen <- getStdGen
let bstr = bbop 15 gen
putStrLn $ bbfold 14 bstr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment