This blog mines cryptocurrency for the blog's owner.
Loading...

(Haskell) mutation

Programming 2018.04.13 22:55

module Main where

import System.IO

import Data.IORef


main = do

    x <- newIORef (0 :: Int)

    readIORef x >>= print -- 0

    writeIORef x 1

    readIORef x >>= print -- 1

    modifyIORef x (+ 1)

    readIORef x >>= print -- 2


https://en.wikibooks.org/wiki/Haskell/Mutable_objects

Posted by steloflute


Generate bitcoin for me

What's this?