Created
August 15, 2013 18:15
-
-
Save dvdsgl/6243245 to your computer and use it in GitHub Desktop.
A $12 million Haskell program.
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.Exit | |
import Control.Monad | |
import Control.Concurrent | |
import Control.Concurrent.MVar | |
main = do | |
currentPos <- newMVar (1, 2) | |
forkIO $ forever $ do | |
(x, y) <- readMVar currentPos | |
when (x + 1 /= y) $ do | |
putStrLn $ show x ++ " " ++ show y | |
exitFailure | |
-- Update forever | |
forever $ do | |
(x, y) <- takeMVar currentPos | |
putMVar currentPos (x + 1, y + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment