Created
September 8, 2014 06:16
-
-
Save gyk/fdc7c72c10c0bb478f56 to your computer and use it in GitHub Desktop.
Test nested do blocks in Haskell
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
xRange = [2, 3] | |
yRange = [4..6] | |
lComprehension = [[(x, y) | y <- yRange] | x <- xRange] | |
lOperator = xRange >>= (\x -> [yRange >>= \y -> [(x, y)]]) | |
lNestedDo = do | |
x <- xRange | |
return $ do | |
y <- yRange | |
return (x, y) | |
main = do | |
putStrLn $ show lComprehension | |
putStrLn $ show lOperator | |
putStrLn $ show lNestedDo | |
{-- | |
Results: | |
Three lines of [[(2,4),(2,5),(2,6)],[(3,4),(3,5),(3,6)]] | |
--} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment