Skip to content

Instantly share code, notes, and snippets.

@zecl
Last active September 8, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zecl/b087ed7d36bfd38221de to your computer and use it in GitHub Desktop.
Save zecl/b087ed7d36bfd38221de to your computer and use it in GitHub Desktop.
module Sample
let counter =
let makeCounter () =
let i = ref 0
fun () ->
i := !i + 1
!i
makeCounter ()
[<EntryPoint>]
let main _ =
printfn "%d" <| counter () //1
printfn "%d" <| counter () //2
printfn "%d" <| counter () //3
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment