# \#lists

**URL:** https://forum.elixirforum.com/tag/lists/66.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [How does List vs Tuple preformance work](https://forum.elixirforum.com/t/how-does-list-vs-tuple-preformance-work/74397)

<div class="topic-metadata">

**Author:** [@Trolleger](https://forum.elixirforum.com/u/Trolleger)\
**Replies:** 2\
**Last updated:** [February 24, 2026, 9:02pm UTC](https://forum.elixirforum.com/t/how-does-list-vs-tuple-preformance-work/74397 "2026-02-24T21:02:08Z")

</div>

I heard that editing a tuple is a much more expensive operation then editing a list i just don’t get the why, when a list is mutated a new list made in memory when edited, same as tuple; they use references from other v…

---

## [Can you improve this? Zipping two lists, the result must be same size as the first list](https://forum.elixirforum.com/t/can-you-improve-this-zipping-two-lists-the-result-must-be-same-size-as-the-first-list/45800)

<div class="topic-metadata">

**Author:** [@dimitarvp](https://forum.elixirforum.com/u/dimitarvp)\
**Replies:** 46\
**Last updated:** [June 11, 2025, 7:27pm UTC](https://forum.elixirforum.com/t/can-you-improve-this-zipping-two-lists-the-result-must-be-same-size-as-the-first-list/45800 "2025-06-11T19:27:26Z")

</div>

Heya. I am inviting you to copy-paste the module below and add your own functions and measure them, or simply give other ideas about how the desired result can be produced best. I got interested in writing a function t…

---

## [TaggedTupleShorthand - Field Punning in Elixir](https://forum.elixirforum.com/t/taggedtupleshorthand-field-punning-in-elixir/68298)

<div class="topic-metadata">

**Author:** [@christhekeele](https://forum.elixirforum.com/u/christhekeele)\
**Replies:** 3\
**Last updated:** [December 23, 2024, 7:28am UTC](https://forum.elixirforum.com/t/taggedtupleshorthand-field-punning-in-elixir/68298 "2024-12-23T07:28:41Z")

</div>

Hey all! I’m releasing TaggedTupleShorthand today as an experiment with Elixir syntax. Field Punning The aim of the library is to support a commonly-requested Elixir feature1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17: S…

---

## [nm - a tool to work with deeply nested data structures](https://forum.elixirforum.com/t/nm-a-tool-to-work-with-deeply-nested-data-structures/67073)

<div class="topic-metadata">

**Author:** [@cevado](https://forum.elixirforum.com/u/cevado)\
**Replies:** 1\
**Last updated:** [October 29, 2024, 11:59am UTC](https://forum.elixirforum.com/t/nm-a-tool-to-work-with-deeply-nested-data-structures/67073 "2024-10-29T11:59:53Z")

</div>

I’ve just publish something I’ve been experimenting with: Since the discussion about local accumulators I’ve joined some discussions on ways to deal with it properly. I’ve always argued that this is difficult and yes,…

---

## [Range guard not working with function that takes a list](https://forum.elixirforum.com/t/range-guard-not-working-with-function-that-takes-a-list/64900)

<div class="topic-metadata">

**Author:** [@joshua.aug](https://forum.elixirforum.com/u/joshua.aug)\
**Replies:** 1\
**Last updated:** [July 14, 2024, 7:09am UTC](https://forum.elixirforum.com/t/range-guard-not-working-with-function-that-takes-a-list/64900 "2024-07-14T07:09:22Z")

</div>

I have a function that takes a list as input. If I call the function with a range e.g. 0..3 it doesn’t work. I assume I need to make another function with same signature that has a check that the input is range as the g…

---

## [Return true if a list has duplicates otherwise false](https://forum.elixirforum.com/t/return-true-if-a-list-has-duplicates-otherwise-false/22709)

<div class="topic-metadata">

**Author:** [@Andres](https://forum.elixirforum.com/u/Andres)\
**Replies:** 14\
**Last updated:** [July 7, 2024, 8:58pm UTC](https://forum.elixirforum.com/t/return-true-if-a-list-has-duplicates-otherwise-false/22709 "2024-07-07T20:58:56Z")

</div>

Hello. I’m trying to check if a list has duplicates. I didn’t have problems doing it with length and size: def duplicate(list) do a = length(list) b = MapSet.size(MapSet.new(list)) a !== b end I also did …

---

## [Seeking feedback on my understanding of linked lists](https://forum.elixirforum.com/t/seeking-feedback-on-my-understanding-of-linked-lists/63990)

<div class="topic-metadata">

**Author:** [@spencer.christensen](https://forum.elixirforum.com/u/spencer.christensen)\
**Replies:** 2\
**Last updated:** [June 4, 2024, 10:55pm UTC](https://forum.elixirforum.com/t/seeking-feedback-on-my-understanding-of-linked-lists/63990 "2024-06-04T22:55:12Z")

</div>

Greetings friends! I am reading through SCIP and using Elixir to help me work through the material (to better understand both the material itself and how Elixir works). Livebook is a great tool for such work! Anyways, …

---

## [Why is \[1, 2, 3 | 4\] a valid list if lists are linked lists?](https://forum.elixirforum.com/t/why-is-1-2-3-4-a-valid-list-if-lists-are-linked-lists/63965)

<div class="topic-metadata">

**Author:** [@spencer.christensen](https://forum.elixirforum.com/u/spencer.christensen)\
**Replies:** 9\
**Last updated:** [June 3, 2024, 11:09pm UTC](https://forum.elixirforum.com/t/why-is-1-2-3-4-a-valid-list-if-lists-are-linked-lists/63965 "2024-06-03T23:09:11Z")

</div>

I did not formally study Computer Science, so please bear with me if I am missing something obvious. I am studying the inner workings of functional programming concepts and wrote this simplistic map function: defmodule …

---

## [A BIG thanks to the LiveView team for introducing managed lists (streams)](https://forum.elixirforum.com/t/a-big-thanks-to-the-liveview-team-for-introducing-managed-lists-streams/53839)

<div class="topic-metadata">

**Author:** [@DaAnalyst](https://forum.elixirforum.com/u/DaAnalyst)\
**Replies:** 13\
**Last updated:** [February 7, 2024, 1:05am UTC](https://forum.elixirforum.com/t/a-big-thanks-to-the-liveview-team-for-introducing-managed-lists-streams/53839 "2024-02-07T01:05:34Z")

</div>

As per the headline, I hereby use the opportunity to thank the LiveView team for finally introducing (as of v0.18.12) the long awaited mechanism for managing the lists - streams. So far, the only way to do it was with c…

---

## [Append to list after Enum.map. How to do this efficiently?](https://forum.elixirforum.com/t/append-to-list-after-enum-map-how-to-do-this-efficiently/47626)

<div class="topic-metadata">

**Author:** [@odohMei7](https://forum.elixirforum.com/u/odohMei7)\
**Replies:** 14\
**Last updated:** [December 22, 2023, 6:05pm UTC](https://forum.elixirforum.com/t/append-to-list-after-enum-map-how-to-do-this-efficiently/47626 "2023-12-22T18:05:57Z")

</div>

How can I efficiently append one entry to a list? Is this the best solution: history = \[{1,100}, {2,300}, {3,200}\] current = {4,150} chart = Enum.map(history,&Tuple.to\_list(&1)) ++ \[Tuple.to\_list(current)\]|\>Jason.encod…

---

## [Need help with this nested list](https://forum.elixirforum.com/t/need-help-with-this-nested-list/60486)

<div class="topic-metadata">

**Author:** [@chmod777](https://forum.elixirforum.com/u/chmod777)\
**Replies:** 3\
**Last updated:** [December 21, 2023, 1:38pm UTC](https://forum.elixirforum.com/t/need-help-with-this-nested-list/60486 "2023-12-21T13:38:41Z")

</div>

I have the following list: \[ :juridical\_person\_document, \[re\_developments: \[\[properties: \[\[re\_development: \[:re\_developer\]\]\]\]\]\], :legal\_address \] And my desired output would be this: \[ :juridical\_person\_docum…

---

## [Keep a list of connection pids, with urls as keys](https://forum.elixirforum.com/t/keep-a-list-of-connection-pids-with-urls-as-keys/58729)

<div class="topic-metadata">

**Author:** [@RooSoft](https://forum.elixirforum.com/u/RooSoft)\
**Replies:** 5\
**Last updated:** [October 5, 2023, 9:57pm UTC](https://forum.elixirforum.com/t/keep-a-list-of-connection-pids-with-urls-as-keys/58729 "2023-10-05T21:57:59Z")

</div>

I am keeping connections to a list of servers represented by URLs. Each of them has a pid if connected. Ideally, I’d like to have a simple list only containing the connected ones. It should also be possible to index by …

---

## [Creating a nested list from a flat list](https://forum.elixirforum.com/t/creating-a-nested-list-from-a-flat-list/56561)

<div class="topic-metadata">

**Author:** [@scandingo](https://forum.elixirforum.com/u/scandingo)\
**Replies:** 4\
**Last updated:** [June 18, 2023, 12:38pm UTC](https://forum.elixirforum.com/t/creating-a-nested-list-from-a-flat-list/56561 "2023-06-18T12:38:23Z")

</div>

I’m new to functional programming and I’d like to know the idiomatic way to convert a flat list of maps into a nested list. For some background, I’m experimenting with Ecto. I have a table with a recursive relationship …

---

## [Find a specific string in an unstructured and nested list](https://forum.elixirforum.com/t/find-a-specific-string-in-an-unstructured-and-nested-list/53918)

<div class="topic-metadata">

**Author:** [@shahryarjb](https://forum.elixirforum.com/u/shahryarjb)\
**Replies:** 10\
**Last updated:** [February 15, 2023, 2:38pm UTC](https://forum.elixirforum.com/t/find-a-specific-string-in-an-unstructured-and-nested-list/53918 "2023-02-15T14:38:03Z")

</div>

Hi friends, I have a nested list that is unstructured, and I really know how much it has nested list or map in itself. I just need to search and get all :tag key in this list and check the selected name by my user exist…

---

## [Enum over list and insert items from another list at certain indexes?](https://forum.elixirforum.com/t/enum-over-list-and-insert-items-from-another-list-at-certain-indexes/50263)

<div class="topic-metadata">

**Author:** [@CherryPoppins](https://forum.elixirforum.com/u/CherryPoppins)\
**Replies:** 21\
**Last updated:** [January 22, 2023, 7:47pm UTC](https://forum.elixirforum.com/t/enum-over-list-and-insert-items-from-another-list-at-certain-indexes/50263 "2023-01-22T19:47:43Z")

</div>

If I have 2 lists. list\_one a list of values and list\_two a list of tuples that represent {value, index} list\_one = \[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\] list\_two = \[{11, 1}, {12, 3}, {13, 6}\] what is the most performant way…

---

## [Is operating on \[{1}, {2}, ...\] meaningfully less performant than \[{:a, :b, ...}, ...\]](https://forum.elixirforum.com/t/is-operating-on-1-2-meaningfully-less-performant-than-a-b/53227)

<div class="topic-metadata">

**Author:** [@overcomeoj](https://forum.elixirforum.com/u/overcomeoj)\
**Replies:** 2\
**Last updated:** [January 17, 2023, 6:41pm UTC](https://forum.elixirforum.com/t/is-operating-on-1-2-meaningfully-less-performant-than-a-b/53227 "2023-01-17T18:41:13Z")

</div>

Knowing that Elixir lists are linked lists, and that updating them has some performance cost for traversal, etc, does the data in those lists impact performance? Eg, given a “simple” list of \[{1}, {2}, ...\] where the el…

---

## [Creating list adding elements on specific conditions?](https://forum.elixirforum.com/t/creating-list-adding-elements-on-specific-conditions/6295)

<div class="topic-metadata">

**Author:** [@svilen](https://forum.elixirforum.com/u/svilen)\
**Replies:** 8\
**Last updated:** [November 25, 2022, 11:49pm UTC](https://forum.elixirforum.com/t/creating-list-adding-elements-on-specific-conditions/6295 "2022-11-25T23:49:51Z")

</div>

Often I want to create a list in Elixir that contains certain elements, but only if specific conditions are met for each element or group of elements. In a language with mutable data, it would be something like array =…

---

## [I want a list which consists of the indexes of the integers present in a list](https://forum.elixirforum.com/t/i-want-a-list-which-consists-of-the-indexes-of-the-integers-present-in-a-list/51564)

<div class="topic-metadata">

**Author:** [@milindnair](https://forum.elixirforum.com/u/milindnair)\
**Replies:** 12\
**Last updated:** [November 5, 2022, 4:33pm UTC](https://forum.elixirforum.com/t/i-want-a-list-which-consists-of-the-indexes-of-the-integers-present-in-a-list/51564 "2022-11-05T16:33:32Z")

</div>

For ex: for a given list \[1,2,3,4,5,‘a’\] i want output as \[0,1,2,3,4\] but i am getting output \[0\] \[1\] \[2\] \[3\] \[4\] the following is the code which i tried items = \[1,2,3,4,5,“a”\] list = items |\> Enum.with\_ind…

---

## [Check list in list?](https://forum.elixirforum.com/t/check-list-in-list/51192)

<div class="topic-metadata">

**Author:** [@alsaraha](https://forum.elixirforum.com/u/alsaraha)\
**Replies:** 10\
**Last updated:** [October 21, 2022, 1:10am UTC](https://forum.elixirforum.com/t/check-list-in-list/51192 "2022-10-21T01:10:49Z")

</div>

How to check if any item of a list is in another list? for example: \[:a, :b, :c\] in \[:d, :e, :f\] # false \[:a, :b, :c\] in \[:d, :e, :c\] # true

---

## [Help needed with my Wordle attempt](https://forum.elixirforum.com/t/help-needed-with-my-wordle-attempt/50514)

<div class="topic-metadata">

**Author:** [@blackened](https://forum.elixirforum.com/u/blackened)\
**Replies:** 4\
**Last updated:** [September 25, 2022, 4:03pm UTC](https://forum.elixirforum.com/t/help-needed-with-my-wordle-attempt/50514 "2022-09-25T16:03:39Z")

</div>

word = "apple" tempWord = String.codepoints(word) |\> Enum.with\_index() |\> Enum.map(fn {char, index} -\> cond do char == String.at(guess, index) -\> {char, index, :correct} true …

---

## [Optimizing an "almost-increasing" array problem](https://forum.elixirforum.com/t/optimizing-an-almost-increasing-array-problem/49317)

<div class="topic-metadata">

**Author:** [@caleb-bb](https://forum.elixirforum.com/u/caleb-bb)\
**Replies:** 6\
**Last updated:** [August 4, 2022, 12:39am UTC](https://forum.elixirforum.com/t/optimizing-an-almost-increasing-array-problem/49317 "2022-08-04T00:39:29Z")

</div>

Below, the problem specs: Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array. Note: sequence a0, a1,…

---

## [Sort a list of maps like \[%{"some string" =\> weight}\]](https://forum.elixirforum.com/t/sort-a-list-of-maps-like-some-string-weight/46651)

<div class="topic-metadata">

**Author:** [@jpcaruana](https://forum.elixirforum.com/u/jpcaruana)\
**Replies:** 4\
**Last updated:** [March 17, 2022, 10:26pm UTC](https://forum.elixirforum.com/t/sort-a-list-of-maps-like-some-string-weight/46651 "2022-03-17T22:26:39Z")

</div>

I would like to sort that kind of List of weighted maps: \[ %{"this is a string" =\> 24}, %{"en français" =\> 11} \] into a weight ordered List of keys: \["en français", "this is a string"\] I don’t the key names in ad…

---

## [List of attribute lists to a neat map](https://forum.elixirforum.com/t/list-of-attribute-lists-to-a-neat-map/46190)

<div class="topic-metadata">

**Author:** [@webuhu](https://forum.elixirforum.com/u/webuhu)\
**Replies:** 8\
**Last updated:** [February 22, 2022, 5:23pm UTC](https://forum.elixirforum.com/t/list-of-attribute-lists-to-a-neat-map/46190 "2022-02-22T17:23:37Z")

</div>

I wanted to ask for the most elegant solution for the following task. I have a list of attribute lists: attributes = \[ \["color", "head", "red"\], \["color", "head", "green"\], \["color", "body", "blue"\], \["color", …

---

## [\`nil\` or empty list?](https://forum.elixirforum.com/t/nil-or-empty-list/44778)

<div class="topic-metadata">

**Author:** [@Euphorichuman](https://forum.elixirforum.com/u/Euphorichuman)\
**Replies:** 4\
**Last updated:** [December 23, 2021, 2:33am UTC](https://forum.elixirforum.com/t/nil-or-empty-list/44778 "2021-12-23T02:33:34Z")

</div>

I’m managing my Postgres database with Ecto and I have come across a situation: In some of the fields for some of my records, I save empty values: For this case, it would be an empty list \[\]. Empty list or nil, which is…

---

## [How to dynamically create a Map key and add a list of lists as its value?](https://forum.elixirforum.com/t/how-to-dynamically-create-a-map-key-and-add-a-list-of-lists-as-its-value/43887)

<div class="topic-metadata">

**Author:** [@Andres](https://forum.elixirforum.com/u/Andres)\
**Replies:** 2\
**Last updated:** [November 15, 2021, 6:03pm UTC](https://forum.elixirforum.com/t/how-to-dynamically-create-a-map-key-and-add-a-list-of-lists-as-its-value/43887 "2021-11-15T18:03:42Z")

</div>

Hello. I have the following maps list: table = \[ %{column: "firstHeader", rows: \["a", "b", "c"\], tableName: "table1"}, %{column: "secondHeader", rows: \["d", "e", "f"\], tableName: "table1"}, %{column: …

---

## [Enum.reduce and Map.update functionality](https://forum.elixirforum.com/t/enum-reduce-and-map-update-functionality/25839)

<div class="topic-metadata">

**Author:** [@tio407](https://forum.elixirforum.com/u/tio407)\
**Replies:** 6\
**Last updated:** [August 13, 2021, 11:34pm UTC](https://forum.elixirforum.com/t/enum-reduce-and-map-update-functionality/25839 "2021-08-13T23:34:57Z")

</div>

I’m failing to understand what Elixir is doing in this function. The objective is to create a map with each word as a key and how many times that word appears in the sentence as its value. For example: sentence = "one …

---

## [Suggest how to convert list to string with a character](https://forum.elixirforum.com/t/suggest-how-to-convert-list-to-string-with-a-character/40975)

<div class="topic-metadata">

**Author:** [@shahryarjb](https://forum.elixirforum.com/u/shahryarjb)\
**Replies:** 2\
**Last updated:** [July 11, 2021, 8:44pm UTC](https://forum.elixirforum.com/t/suggest-how-to-convert-list-to-string-with-a-character/40975 "2021-07-11T20:44:20Z")

</div>

Hi, I have a list which includes some string or integer item that I need to convert it to string with a character like “/”, then I used Enum.map like bottom code. Enum.map(\["a", "b", "c"\], fn x -\> "#{x}/" end) |\> List.t…

---

## [Reduce array that every element can have an array](https://forum.elixirforum.com/t/reduce-array-that-every-element-can-have-an-array/40256)

<div class="topic-metadata">

**Author:** [@ehayun](https://forum.elixirforum.com/u/ehayun)\
**Replies:** 8\
**Last updated:** [June 6, 2021, 2:28am UTC](https://forum.elixirforum.com/t/reduce-array-that-every-element-can-have-an-array/40256 "2021-06-06T02:28:19Z")

</div>

I have an array that every element in it can have 2 fields that contains array too like that \[ %{name: "a1", ar1: \[%{name: "aa1"}, %{name: "aa2"}, %{name: "aa3"}\], ar2: \[%{department: "a23"}\]}, %{name: "a2…

---

## [Arbitrage logic in Elixir](https://forum.elixirforum.com/t/arbitrage-logic-in-elixir/36857)

<div class="topic-metadata">

**Author:** [@david234](https://forum.elixirforum.com/u/david234)\
**Replies:** 4\
**Last updated:** [January 15, 2021, 3:08pm UTC](https://forum.elixirforum.com/t/arbitrage-logic-in-elixir/36857 "2021-01-15T15:08:53Z")

</div>

This is from my arbitrage project. I need to find the best probability of where the client can buy and where he can sell to get maximum profits. For ex take a look at the below list \[ %{id: BTC, name: "Binance", price…

---

## [Converting an Elixir list into a Python dictionary](https://forum.elixirforum.com/t/converting-an-elixir-list-into-a-python-dictionary/35763)

<div class="topic-metadata">

**Author:** [@Maxximiliann](https://forum.elixirforum.com/u/Maxximiliann)\
**Replies:** 4\
**Last updated:** [November 27, 2020, 10:50pm UTC](https://forum.elixirforum.com/t/converting-an-elixir-list-into-a-python-dictionary/35763 "2020-11-27T22:50:54Z")

</div>

What libraries, if any, can be used to take an Elixir list: \[color: "Red", make: "Mclaren", mileage: 15641.469\] and convert into a Python dictionary - {"color": "Red", "make": "Mclaren", "mileage": 15641.469}? If no su…

[Next page](https://forum.elixirforum.com/tag/lists/66.md?match_all_tags=true&page=1&tags%5B%5D=lists)
