I’ve been trying to use Enum.map with an inner Enum.with_index fetching the columns but it doesn’t make sense when I need to build a map and it also seems quite inefficient…
(I’m a noob)
No worries about being a noob, but as a general note for future questions it’s also best to show the code that you’ve tried so that we can help you learn.
The most succinct way to do this is with Enum.zip. Assuming you have the struct you listed as a result variable you can do:
I’d highly recommend starting with a simpler question and seeing if you can build it from scratch without Enum, it’ll help with those for i cobwebs. Given:
I can only second that. To cleanse yourself from the sins of the imperative world you should reimplement the Enum functions. This is one of the exercises in the Exercism Elixir Track. This is very much recommended! Reimplmenting Enum is not easy, so there are a lot of very good execises to lead you there.
Please keep in mind below every time you want to convert String to Atom:
Warning: this function creates atoms dynamically and atoms are not garbage-collected. Therefore, string should not be an untrusted value, such as input received from a socket or during a web request. Consider using to_existing_atom/1 instead.