Skip to content

Instantly share code, notes, and snippets.

@mgryszko
Created February 9, 2021 05:31
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 mgryszko/8c5d74f7926c01f572f63d9b482fa0c3 to your computer and use it in GitHub Desktop.
Save mgryszko/8c5d74f7926c01f572f63d9b482fa0c3 to your computer and use it in GitHub Desktop.
val pricers = List(priceByTier, priceByUnit)
val (_, total) = pricers.foldLeft((quantity, BigDecimal(0))) {
case ((quantity, total), pricer) =>
val (remainingQuantity, amount) = pricer(quantity)
(remainingQuantity, total + amount)
}
total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment