Jump to content

RPG attributes generator: Difference between revisions

m
→‎{{header|Haskell}}: Desugared `do` to >>=
m (→‎{{header|Haskell}}: Desugared `do` to >>=)
Line 253:
(replicateM 6 $
(sum . tail . sort) <$> replicateM 4 (randomRIO (1, 6 :: Int)))
 
 
discardUntil :: ([Int] -> Bool) -> IO [Int] -> IO [Int]
discardUntil p throw =
let go = do
xthrow <- throw>>=
if(\x p x->
then return if p x
else go then return x
else go)
in go
 
 
-- TEST -----------------------------------------------------------
main :: IO ()
main = replicateM 10 character >>= mapM_ (print . (sum >>= (,))) xs</lang>
main = do
xs <- replicateM 10 character
mapM_ (print . (sum >>= (,))) xs</lang>
{{Out}}
<pre>Sample computation:
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.