September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -4,9 +4,9 @@ import Control.Monad
sleepSort :: [Int] -> IO ()
sleepSort values = do
chan <- newChan
forM_ values (\time -> forkIO (threadDelay (50000 * time) >> writeChan chan time))
forM_ values (const (readChan chan >>= print))
chan <- newChan
forM_ values (\time -> forkIO (threadDelay (50000 * time) >> writeChan chan time))
forM_ values (\_ -> readChan chan >>= print)
main :: IO ()
main = getArgs >>= sleepSort . map read

View file

@ -2,8 +2,8 @@ import System.Environment
import Control.Concurrent
import Control.Concurrent.Async
sleepSort :: [Int] -> IO [()]
sleepSort = mapConcurrently (\x -> threadDelay (x*10^4) >> print x)
sleepSort :: [Int] -> IO ()
sleepSort = (() <$) . mapConcurrently (\x -> threadDelay (x*10^4) >> print x)
main :: IO [()]
main :: IO ()
main = getArgs >>= sleepSort . map read