<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="306074" data-post-id="306074">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I hate how people immediately decided that ChatGPT is credible. <img src="https://forum.elixirforum.com/images/emoji/apple/downcast_face_with_sweat.png?v=15" title=":downcast_face_with_sweat:" class="emoji" alt=":downcast_face_with_sweat:" loading="lazy" width="20" height="20"></p>
<p>It hallucinates, and it does it well for the areas where it had trillion+ trainings / tokens. For everything else you might as well ask the local grocery store seller lady, she’ll give you a better answer. <img src="https://forum.elixirforum.com/images/emoji/apple/grin.png?v=15" title=":grin:" class="emoji" alt=":grin:" loading="lazy" width="20" height="20"></p>
<p>But apart from that, I don’t get it how actually onboarding yourself in the language is viewed as this monumental task that should never be done. Boggles my mind. We’re not talking about Rust and OCaml here, which might easily take you <em>months</em> to properly onboard, we’re talking Elixir where one weekend is enough to start writing apps and parallel code and make a Phoenix project even.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="306074" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/retrieving-information-from-a-list-of-maps/59294/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-306074" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="306074"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #41"></div>
  </section>
</div>
    <div class="postbit" id="306082" data-post-id="306082">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ken-kost" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ken-kost/120/40209_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ken-kost
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I asked<br>
‘How do I transform a list of maps in elixir?’</p>
<p>In Elixir, you can transform a list of maps using functions like <code>Enum.map/2</code> or <code>Enum.reduce/3</code>. Here’s an example of how you can use <code>Enum.map/2</code> to transform a list of maps:</p>
<p>Suppose you have a list of maps like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">list_of_maps = [
  %{name: "Alice", age: 30},
  %{name: "Bob", age: 25},
  %{name: "Charlie", age: 35}
]
</code></pre>
<p>And you want to double the age in each map. You can do it like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">transformed_list = Enum.map(list_of_maps, fn %{name: name, age: age} -&gt;
  %{name: name, age: age * 2}
end)
</code></pre>
<p>After this transformation, <code>transformed_list</code> will contain the updated maps with doubled ages.</p>
<p>You can adjust the function inside <code>Enum.map/2</code> to perform the specific transformation you need on the maps in your list.</p>
<p>I also asked how to do it with reduce. Did do not hallucinate and def knew better than grocery lady lol.<br>
I agree, onboarding yourself to the language by going through getting started and docs is a must but <a class="mention" href="/u/roganjoshua" rel="nofollow">@roganjoshua</a> is solving a problem and is stuck. You tried to help, maybe chat gpt can also help - my point.</p>
<p><a class="mention" href="/u/benwilson512" rel="nofollow">@benwilson512</a> You could tell by running the code in iex. A beginner will not tackle a complex problem, nor will you ask chat gpt to solve a complex problem but learning to break down a problem and asking simple questions, don’t see nothing wrong with that. I feel chat gpt can be a great learning companion if used thoughtfully of course, but I’m actually interested if <a class="mention" href="/u/roganjoshua" rel="nofollow">@roganjoshua</a> tried and what does he think?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="306082" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/retrieving-information-from-a-list-of-maps/59294/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-306082" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="306082"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #42"></div>
  </section>
</div>
    <div class="postbit" id="306090" data-post-id="306090">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>OK, so somebody in OpenAI noticed ChatGPT is doing badly with Elixir and gave it better Elixir inputs. Cool.</p>
<aside class="quote no-group" data-username="ken-kost" data-post="43" data-topic="59294">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ken-kost/48/40209_2.png" class="avatar"> ken-kost:</div>
<blockquote>
<p>You tried to help</p>
</blockquote>
</aside>
<p>I didn’t really try to help with OP’s problem, I tried to guide them to arrive at the solution themselves. IMO this forum is super helpful but there’s also a balance to be struck – we want people to get better, not for us to become unpaid support group solving other people’s homework (or urgent work tasks).</p>
<p>I formulated the code for OP’s solution literally during reading their original post and could have just posted it – but they have to learn, otherwise next time they’ll come here again with the next problem and so on to infinity, which obviously doesn’t scale. We had posters in the past that tried this and we quickly stopped responding altogether to them. We do <em>not</em> want for that to happen so we try guiding people instead. We want people to learn. That’s why <a class="mention" href="/u/benwilson512" rel="nofollow">@benwilson512</a> very often starts off a thread with: “What have you tried?”. It’s a gentle reminder that the people here are willing to help if you tried and failed and got confused (while <em>ACTUALLY KNOWING ELIXIR!</em>), but not if you haven’t even tried (“not trying” includes “not really knowing the basics of Elixir”).</p>
<p>And btw most beginners HUGELY MISS OUT on the official guide because it also teaches them how to experiment in <code>iex</code>, something that not that many programming languages actually have – and is a hugely empowering tool! Helps you iterate quickly.</p>
<aside class="quote no-group" data-username="ken-kost" data-post="43" data-topic="59294">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ken-kost/48/40209_2.png" class="avatar"> ken-kost:</div>
<blockquote>
<p>but learning to break down a problem and asking simple questions, don’t see nothing wrong with that</p>
</blockquote>
</aside>
<p>No machine can replace humans at that yet. ChatGPT will just give you the answer with some little explanation. Correct me if I am wrong, the approach I took felt better to me: “don’t think about the list of records, let’s do the job for one record first” for example.</p>
<p>I am not saying that ChatGPT won’t evolv… – errr, will not have an army of engineers to manually enrich its DB, excuse me! (<img src="https://forum.elixirforum.com/images/emoji/apple/winking_face_with_tongue.png?v=15" title=":winking_face_with_tongue:" class="emoji" alt=":winking_face_with_tongue:" loading="lazy" width="20" height="20">) – to do what I and others do. I’d be glad if we get machine pedagogues at one point, seriously. But so far I am not seeing any signs of that happening.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="306090" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/retrieving-information-from-a-list-of-maps/59294/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-306090" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="306090"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #43"></div>
  </section>
</div>
    <div class="postbit" id="306130" data-post-id="306130">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lud" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/120/14382_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lud
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You’re almost there <a class="mention" href="/u/roganjoshua" rel="nofollow">@roganjoshua</a> . Keep up <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Mapping, reducing etc. can be hard at the beginning if you are more used to loops and mutable state. And honetly those operations will always be a bit more convoluted and verbose in a functional language. But soon enough you will feel it natural if you practice.</p>
<p>So, with this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"> |&gt; Enum.map( fn item -&gt; {"Customer", item["value"]} end)
</code></pre>
<p>You get this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[
  {"Customer", "EOG.Acme.ManualXML"},
  {"Customer",
   "{\"variables\":{\"CUSTOMER\":\"EOG.Acme.ManualXML\",\"VERSION\":\"Version-8.6.2\"},\"id\":\"5112\",\"ref\":\"main\"}"},
  {"Customer", "Version-8.6.2"}
]
</code></pre>
<p>The data looks like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[
  %{
    "key" =&gt; "CUSTOMER",
    "raw" =&gt; false,
    "value" =&gt; "EOG.Acme.ManualXML",
    "variable_type" =&gt; "env_var"
  },
  %{
    "key" =&gt; "TRIGGER_PAYLOAD",
    "raw" =&gt; false,
    "value" =&gt; "{\"variables\":{\"CUSTOMER\":\"EOG.Acme.ManualXML\",\"VERSION\":\"Version-8.6.2\"},\"id\":\"5112\",\"ref\":\"main\"}",
    "variable_type" =&gt; "file"
  },
  %{
    "key" =&gt; "VERSION",
    "raw" =&gt; false,
    "value" =&gt; "Version-8.6.2",
    "variable_type" =&gt; "env_var"
  }
]
</code></pre>
<p>What single change can you make to your code to get this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[
  {"CUSTOMER", "EOG.Acme.ManualXML"},
  {"TRIGGER_PAYLOAD",
   "{\"variables\":{\"CUSTOMER\":\"EOG.Acme.ManualXML\",\"VERSION\":\"Version-8.6.2\"},\"id\":\"5112\",\"ref\":\"main\"}"},
  {"VERSION", "Version-8.6.2"}
]
</code></pre>
<p>?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"></code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="306130" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/retrieving-information-from-a-list-of-maps/59294/45">Post #44</a>
	                </div>
	            </div>
              <div id="likers-container-306130" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="306130"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #44"></div>
  </section>
</div>
    <div class="postbit" id="306156" data-post-id="306156">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="roganjoshua" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/roganjoshua/120/30250_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  roganjoshua
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So I think after a bit more reading<br>
I can get from</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[
  %{
    "key" =&gt; "CUSTOMER",
    "raw" =&gt; false,
    "value" =&gt; "EOG.Acme.ManualXML",
    "variable_type" =&gt; "env_var"
  },
  %{
    "key" =&gt; "TRIGGER_PAYLOAD",
    "raw" =&gt; false,
    "value" =&gt; "{\"variables\":{\"CUSTOMER\":\"EOG.Acme.ManualXML\",\"VERSION\":\"Version-8.6.2\"},\"id\":\"5112\",\"ref\":\"main\"}",
    "variable_type" =&gt; "file"
  },
  %{
    "key" =&gt; "VERSION",
    "raw" =&gt; false,
    "value" =&gt; "Version-8.6.2",
    "variable_type" =&gt; "env_var"
  }
]
</code></pre>
<p>Because I only want the value for CUSTOME and VERSION</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">|&gt; Enum.filter(fn %{key: key} -&gt; key == "CUSTOMER" or key == "VERSION" end) 
|&gt; Enum.map(fn item -&gt; item[:value] end)

["EOG.Acme.ManualXML", "Version-8.6.2"]
</code></pre>
<p>Which is quite close but I think if “key” was key: and “value” was value:</p>
<p>The main takeaway so far is</p>
<ul>
<li>Far more interest than I thought I would get</li>
<li>iex is great but iex -S mix phx.server is fantastic</li>
<li>dbg/2 (why this is dbg and not debug?)</li>
<li>RTFM</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="306156" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/retrieving-information-from-a-list-of-maps/59294/46">Post #45</a>
	                </div>
	            </div>
              <div id="likers-container-306156" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="306156"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>