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.49 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.48 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.47 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.46 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.45 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.44 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.43 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.42 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.41 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.40 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.39 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.38 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.37 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.36 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.35 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.34 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.33 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.32 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.31 tracks/fsharp/exercises/bank-account/Example.fs
trackler-2.2.1.30 tracks/fsharp/exercises/bank-account/Example.fs