Tracks
/
Prolog
Prolog
/
Exercises
/
Bank Account
Bank Account

Bank Account

Easy

Instructions

Simulate a bank account supporting opening/closing, withdrawals, and deposits of money. Watch out for concurrent transactions!

A bank account can be accessed in multiple ways. Clients can make deposits and withdrawals using the internet, mobile phones, etc. Shops can charge against the account.

Create an account that can be accessed from multiple threads/processes (terminology depends on your programming language).

It should be possible to close an account; operations against a closed account must fail.

Mutable data in Prolog

By default, values in Prolog are immutable, which means that values never change (you'll have to introduce a new variable for each new value). While this is great for the vast majority of use cases, this exercise does require mutating values. To mutate data in Prolog, you can use the setarg predicate.

Edit via GitHub The link opens in a new window or tab
Prolog Exercism

Ready to start Bank Account?

Sign up to Exercism to learn and master Prolog with 104 exercises, and real human mentoring, all for free.