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.109 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.108 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.107 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.106 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.105 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.104 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.103 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.102 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.101 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.100 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.99 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.98 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.97 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.96 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.95 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.94 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.93 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.92 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.91 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.90 tracks/fsharp/exercises/bank-account/Example.fs