Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(practice).
- -export([product/1, max_of_list/1]).
- % Return the product of the elements of the list
- product(X) -> product(X, 1).
- product([], Acc) -> Acc;
- product([X|Xs], Acc) -> product(Xs, X*Acc).
- % Return the max of the list
- max_of_list([X|Xs]) -> max_of_list(Xs, X).
- max_of_list([X], Max) -> erlang:max(X, Max);
- max_of_list([X|Xs], Max) -> max_of_list(Xs, erlang:max(X, Max)).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement