Last active
April 17, 2020 07:54
-
-
Save elbrujohalcon/12839dab63bba306342430cfe57bb17f 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
get_status_map(StormidMap) -> | |
get_status_map(?SEVERITY, StormidMap, #{}). | |
get_status_map([], _, Acc) -> Acc; | |
get_status_map([Status|Statuses], StormidMap, Acc) -> | |
NewAcc = Acc#{Status => get_storms(Status, maps:values(StormidMap))}, | |
get_status_map(Statuses, StormidMap, NewAcc). | |
get_storms(Status, Storms) -> | |
get_storms(Status, Storms, []). | |
get_storms(_, [], Acc) -> Acc; | |
get_storms(Status, [Storm|Storms], Acc) -> | |
{storm, Id, _, _, _, Name, Observations} = Storm, | |
NewAcc = case get_observations(Status, Observations) of | |
[] -> Acc; %% If there are no observations with the corresponding status, this storm is not added | |
Os -> [{Id, Name, Os} | Acc] | |
end, | |
get_storms(Status, Storms, NewAcc). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment