Skip to content

Instantly share code, notes, and snippets.

@elbrujohalcon
Last active April 17, 2020 07:54
Show Gist options
  • Save elbrujohalcon/12839dab63bba306342430cfe57bb17f to your computer and use it in GitHub Desktop.
Save elbrujohalcon/12839dab63bba306342430cfe57bb17f to your computer and use it in GitHub Desktop.
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