Follow

I'm trying Elixir and my brain is melting.

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 hahaha functional programming with Elixir is very different to other languages

I really enjoyed learning elixir haha

@aynish I'm trying new languages and paradigms to see of it "clicks" more than traditional OOP. Classes were never my thing.

@thomasorus one of my favourite languages and runtimes! Enjoy.

@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
Merveilles

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.