Implementing Specials

Take a look at the implementation of the specials module.

The implementation

A simple method is to count how many of each item is in the list. Account for the specials first, reducing the count every time the specials apply, and then run over the list of items that are not on sale.

-type item() :: string().
-type price() :: integer().
-type special() :: {item(), pos_integer(), price()}.

-spec total([item()], [{item(), price()}], [special()]) -> price(). 
total(ItemList, PriceList, Specials) ->
    Counts =
...
Access this course and 1400+ top-rated courses and projects.