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.89 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.88 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.87 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.86 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.85 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.84 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.83 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.82 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.81 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.80 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.79 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.78 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.77 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.76 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.75 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.74 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.73 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.72 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.71 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.70 tracks/fsharp/exercises/bank-account/Example.fs