And also, each item in the list will be a map, you do not return the 5 from your called function in any way.
If you could explain more indepth what you want to achieve we could help you, though if you just want to statically set xx to 5, then do xx = 5 instead of xx = 0…
The global variable is a common approach in imperative languages, but not the one you should use in Elixir. Try, for example, to use reduce instead of map so you have control on the return values.
Also consider that Elixir data structures are immutable, so when you put a value into a map you get a new map, as opposed to mutating the original map. The original is still available as long as you don’t rebind its variable. Would this help you to keep track of the “original” and the “final” b?