% % Apple Store Utilities. % By Alan. % -module(storeUtils). -export([total/1, test/0]). % % -- Public -- % total([ {What, HowMany} | Tail ]) -> (intVal(store:cost(What))*HowMany) + total(Tail); total([ Head | Tail ]) -> (intVal(store:cost(Head))) + total(Tail); total([]) -> 0. test() -> 3199 = total([iMac, iPad]), 1798 = total([iPhone, iPad]), 'The tests have passed.'. % % -- Private -- % intVal(Val) when is_integer(Val) -> Val; intVal(_) -> 0.