You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
275 B
14 lines
275 B
5 years ago
|
-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()].
|