Last active
October 23, 2018 10:47
-
-
Save KamilaBorowska/d188ce586221fb80593f30b6695d170b to your computer and use it in GitHub Desktop.
This file contains 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 Data.IORef | |
for init cond inc block = do | |
let loop = do | |
res <- cond | |
if res then | |
do | |
block | |
inc | |
loop | |
else | |
return () | |
init | |
loop | |
main = do | |
i <- newIORef (1) | |
for | |
(return ()) | |
(do | |
i <- readIORef i | |
return (i <= 100) | |
) | |
(do | |
iv <- readIORef i | |
writeIORef i (iv + 1) | |
) | |
(do | |
iv <- readIORef i | |
print iv | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment