Help required in Elixir. Trying to convert each element of a list to a map with my own key, and only finding examples using .chunk_every(2) which does not do what I want.

Basically how do I transform this:

['a', 'b', 'c']

into this:

[%{text: a},
%{text: b},
%{text: c}]

@thomasorus something like

Enum.each([a, b, c], into: %{text: })?

@aynish It's almost this, but how do I recover the current value being processed?

For example I tried this:

Enum.each(blocks, fn x -> %{text: x} end)

But the blocks var doesn't change.

@thomasorus so you're saying you always get the full list in your unnamed function? hmmm

Sign in to participate in the conversation

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.