Skip to content

Instantly share code, notes, and snippets.

@dennermiranda
Last active April 24, 2017 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennermiranda/45b63a26b1d3d3f3e7a2963ed3892484 to your computer and use it in GitHub Desktop.
Save dennermiranda/45b63a26b1d3d3f3e7a2963ed3892484 to your computer and use it in GitHub Desktop.
private def getBalanceAmountR(valAmount: Double, operations: List[Operation]): Double = operations match{
case Nil => valAmount
case Purchase(_, value, _, _):: tail => valAmount - getBalanceAmountR(valAmount, tail)
case Deposit(_, value, _, _):: tail => valAmount + getBalanceAmountR(valAmount, tail)
case Withdrawal(_, value, _, _)::tail => valAmount - getBalanceAmountR(valAmount, tail)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment