September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue