Programming

(Haskell) mutation

steloflute 2018. 4. 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

'Programming' 카테고리의 다른 글

(C#) Console.ReadLine은 254자까지만 읽을 수 있다.  (0) 2018.05.10
10 things Idris improved over Haskell  (0) 2018.04.27
(Solved) Free Pascal IDE startup error  (0) 2018.04.10
Turbo Pascal 7.0  (0) 2018.04.05
QuickBASIC 4.5  (0) 2018.03.29