~statianzo/sevenlangs

sevenlangs/erlang/shopping.erl -rw-r--r-- 275 bytes
2fcd4511Jason Staten day one logic style 1 year, 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
-module(shopping).

-export([totals/0]).

% constantize items/0
% https://stackoverflow.com/a/10863003/88340
-compile({inline, [{items, 0}]}).

items() -> [{apple, 5, 2}, {banana, 10, 3}].

totals() ->
    [{Key, Quantity * Price}
     || {Key, Quantity, Price} <- items()].