YoshikuniJujo on Nostr: /run haskell import Data.List import System.Random format :: String -> [Char] -> ...
/run haskell
import Data.List
import System.Random
format :: String -> [Char] -> String
format "" _ = ""
format ('_' : s) (c : cs) = c : format s cs
format (c : s) cs = c : format s cs
shuffle :: [a] -> IO [a]
shuffle xs =
(permutations xs !!) <$> randomRIO (0, product [1 .. length xs])
main = putStrLn . format "_ニ_リーム_ロッ_" =<< shuffle "カクケコ"
Published at
2024-05-15 02:40:24 UTCEvent JSON
{
"id": "bc979bbc1a80a992ec7e9dab6940c94bd452e999a7b78dff629bf0a03d6de9c3",
"pubkey": "ef89ee45550f7377284d31e49fc57e5732ffc2b95a7bf35d0f1291d6fa278758",
"created_at": 1715740824,
"kind": 1,
"tags": [],
"content": "/run haskell\n\nimport Data.List\nimport System.Random\n\nformat :: String -\u003e [Char] -\u003e String\nformat \"\" _ = \"\"\nformat ('_' : s) (c : cs) = c : format s cs\nformat (c : s) cs = c : format s cs\n\nshuffle :: [a] -\u003e IO [a]\nshuffle xs =\n (permutations xs !!) \u003c$\u003e randomRIO (0, product [1 .. length xs])\n\nmain = putStrLn . format \"_ニ_リーム_ロッ_\" =\u003c\u003c shuffle \"カクケコ\"",
"sig": "23af7f82180a0108aa49e1b4ac3464d344abbed04a5d434facc27d26c990443847d037f3ef0a788cb277aa6d167c82448ffdefb3c0098a1898054e8ead181a1e"
}