Sha256: 5f82988a07c5df0280d1b2b5ff2d1b7d01e11aab1a1a7a79afd6936e9c4fba53

Contents?: true

Size: 690 Bytes

Versions: 301

Compression:

Stored size: 690 Bytes

Contents

module BankAccount

open System

type BankAccount() = 
    member val Lock = new Object()
    member val Balance: float option = None with get,set

let mkBankAccount() = BankAccount()

let openAccount (account: BankAccount) = 
    lock account.Lock (fun () ->
        account.Balance <- Some 0.0
        account
    )

let closeAccount (account: BankAccount) = 
    lock account.Lock (fun () ->
        account.Balance <- None    
        account
    )

let getBalance (account: BankAccount) = account.Balance

let updateBalance change (account: BankAccount) = 
    lock account.Lock (fun () ->
        account.Balance <- Option.map ((+) change) account.Balance    
        account
    )

Version data entries

301 entries across 301 versions & 1 rubygems

Version Path
trackler-2.2.1.130 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.129 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.128 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.127 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.126 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.125 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.124 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.123 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.122 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.121 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.120 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.119 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.118 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.117 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.116 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.115 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.114 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.113 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.111 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.110 tracks/fsharp/exercises/bank-account/Example.fs