Skip to content

Instantly share code, notes, and snippets.

@KamilaBorowska
Last active October 23, 2018 10:47
Show Gist options
  • Save KamilaBorowska/d188ce586221fb80593f30b6695d170b to your computer and use it in GitHub Desktop.
Save KamilaBorowska/d188ce586221fb80593f30b6695d170b to your computer and use it in GitHub Desktop.
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