I have an Enum of maps and when a map has a category, that should be the category for the next maps, until I find another map that has a new category.
Let me explain it better with an example.
[
%{"category" => "FIRST CATEGORY", "code" => 0},
%{
"code" => 34,
"name" => "jack"
},
%{
"code" => 22,
"name" => "mary"
},
%{"category" => "SECOND CATEGORY", "code" => 0},
%{
"code" => 1023,
"name" => "john"
},
%{
"code" => 135,
"name" => "lucy"
},
%{
"code" => 2,
"name" => "leonard"
},
]
Into this:
[
%{
"category" => "FIRST CATEGORY",
"code" => 34,
"name" => "jack"
},
%{
"category" => "FIRST CATEGORY",
"code" => 22,
"name" => "mary"
},
%{
"category" => "SECOND CATEGORY",
"code" => 1023,
"name" => "john"
},
%{
"category" => "SECOND CATEGORY",
"code" => 135,
"name" => "lucy"
},
%{
"category" => "SECOND CATEGORY",
"code" => 2,
"name" => "leonard"
},
]