Created
June 20, 2016 18:21
-
-
Save ngnguyen1/05effddbb324d9fa5fdee2cfad8860c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% fold here | |
fold(_, Start, []) -> Start; | |
fold(F, Start, [H|T]) -> fold(F, F(H,Start), T). | |
%% Use fold to write the map function. | |
map(F,L) -> fold(fun(X, Acc) -> [F(X)|Acc] end, [], L). | |
%% Exp: map(fun(X) -> X+1 end, lists:seq(1,3)). => [2,3,4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment