Last active
August 29, 2015 13:56
-
-
Save Nucleareal/9345313 to your computer and use it in GitHub Desktop.
不必要に長いbbop
This file contains hidden or 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
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