# \#tuples

**URL:** https://forum.elixirforum.com/tag/tuples/508.md

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

---

## [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…

---

## [Is there a function to convert an IP address to a tuple, i.e. {127,0,0,1}?](https://forum.elixirforum.com/t/is-there-a-function-to-convert-an-ip-address-to-a-tuple-i-e-127-0-0-1/49405)

<div class="topic-metadata">

**Author:** [@jerry](https://forum.elixirforum.com/u/jerry)\
**Replies:** 7\
**Last updated:** [October 16, 2024, 3:20am UTC](https://forum.elixirforum.com/t/is-there-a-function-to-convert-an-ip-address-to-a-tuple-i-e-127-0-0-1/49405 "2024-10-16T03:20:07Z")

</div>

Is there a standard function to convert an IP address, say, 127.0.0.1 to a tuple,i.e. {127,0,0,1}?

---

## [Keyword inside tuple shorthand syntax {a: 1, b: 2}](https://forum.elixirforum.com/t/keyword-inside-tuple-shorthand-syntax-a-1-b-2/63960)

<div class="topic-metadata">

**Author:** [@bartblast](https://forum.elixirforum.com/u/bartblast)\
**Replies:** 16\
**Last updated:** [June 5, 2024, 5:01pm UTC](https://forum.elixirforum.com/t/keyword-inside-tuple-shorthand-syntax-a-1-b-2/63960 "2024-06-05T17:01:10Z")

</div>

This could resolve to {\[a: 1, b: 2\]}. Was it ever considered to allow such syntax? Notice this: {:abc, a: 1, b: 2} and this: my\_fun(:abc, a: 1, b: 2) work as I described. As I understand, the compiler is able to figure o…

---

## [Destructuring a 3-tuple throws linter warning but still works. Incompatible types: tuple() !~ {var1, var2, var3}](https://forum.elixirforum.com/t/destructuring-a-3-tuple-throws-linter-warning-but-still-works-incompatible-types-tuple-var1-var2-var3/63683)

<div class="topic-metadata">

**Author:** [@warren84](https://forum.elixirforum.com/u/warren84)\
**Replies:** 8\
**Last updated:** [May 21, 2024, 9:36pm UTC](https://forum.elixirforum.com/t/destructuring-a-3-tuple-throws-linter-warning-but-still-works-incompatible-types-tuple-var1-var2-var3/63683 "2024-05-21T21:36:11Z")

</div>

I would like to know what I can do to get rid of the “incompatible types” warnings that are cluttering my phoenix server logs - I would willingly accept “operator error” as the cause if I could learn how to prevent the w…

---

## [Internal data representation of an empty tuple](https://forum.elixirforum.com/t/internal-data-representation-of-an-empty-tuple/58373)

<div class="topic-metadata">

**Author:** [@lykos](https://forum.elixirforum.com/u/lykos)\
**Replies:** 3\
**Last updated:** [September 19, 2023, 8:41am UTC](https://forum.elixirforum.com/t/internal-data-representation-of-an-empty-tuple/58373 "2023-09-19T08:41:56Z")

</div>

Hi, I am trying to figure out why :erts\_debug.size({}) returns 0. The function returns the number of words taken up in the heap. For an empty list, it makes sense since the empty list will be represented by the immediat…

---

## [Pattern matching nested tuples](https://forum.elixirforum.com/t/pattern-matching-nested-tuples/47320)

<div class="topic-metadata">

**Author:** [@ramziabbyad1](https://forum.elixirforum.com/u/ramziabbyad1)\
**Replies:** 4\
**Last updated:** [April 20, 2022, 4:03pm UTC](https://forum.elixirforum.com/t/pattern-matching-nested-tuples/47320 "2022-04-20T16:03:02Z")

</div>

This is listed as one of the “Hard” problem in 7 languages 7 weeks book. "Represent a tree of sentences as tuples. Traverse the tree, presenting an indented list. I think I have solved it, but I’m wondering if there i…

---

## [Quick extraction of elem from tuple - best practice?](https://forum.elixirforum.com/t/quick-extraction-of-elem-from-tuple-best-practice/44985)

<div class="topic-metadata">

**Author:** [@josefrichter](https://forum.elixirforum.com/u/josefrichter)\
**Replies:** 4\
**Last updated:** [January 3, 2022, 1:14pm UTC](https://forum.elixirforum.com/t/quick-extraction-of-elem-from-tuple-best-practice/44985 "2022-01-03T13:14:20Z")

</div>

Hi, I find myself doing something like this, mostly in tests: {:ok, new\_time} = Time.new(15, 00, 00) valid\_attrs = %{ body: "some body", time: new\_time } I wonder if it’s ok to extract the …

---

## [Destructuring a 2-tuple throws linter warning but still works. Incompatible types: tuple() !~ {var1, var2}](https://forum.elixirforum.com/t/destructuring-a-2-tuple-throws-linter-warning-but-still-works-incompatible-types-tuple-var1-var2/42975)

<div class="topic-metadata">

**Author:** [@aegatlin](https://forum.elixirforum.com/u/aegatlin)\
**Replies:** 5\
**Last updated:** [October 10, 2021, 5:16pm UTC](https://forum.elixirforum.com/t/destructuring-a-2-tuple-throws-linter-warning-but-still-works-incompatible-types-tuple-var1-var2/42975 "2021-10-10T17:16:28Z")

</div>

I am trying to destructure a tuple in a case statement and I am getting a warning that confuses me. It passes my test case, so it works, but the linter is giving me a warning and I’m not sure how to handle it. Am I doing…

---

## [Fun with mapping over tuples](https://forum.elixirforum.com/t/fun-with-mapping-over-tuples/42193)

<div class="topic-metadata">

**Author:** [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Replies:** 0\
**Last updated:** [September 6, 2021, 10:52pm UTC](https://forum.elixirforum.com/t/fun-with-mapping-over-tuples/42193 "2021-09-06T22:52:48Z")

</div>

During writing some code related to Arrays , I encountered a situation in which I wanted to map a function over a tuple. Now, code that does this is very easy to write if you know exactly what size of tuple you have. I…

---

## [TaggedTuple](https://forum.elixirforum.com/t/taggedtuple/41693)

<div class="topic-metadata">

**Author:** [@IvanR](https://forum.elixirforum.com/u/IvanR)\
**Replies:** 7\
**Last updated:** [August 17, 2021, 11:27am UTC](https://forum.elixirforum.com/t/taggedtuple/41693 "2021-08-17T11:27:09Z")

</div>

A library to work with tagged tuples. Provides functions to work with chains of tags for nested tuples. Some of the supported operations are: add/remove tag chain to a core value, converting a tuple to list or to map a…

---

## [Why is my random number lookup slow using lists?](https://forum.elixirforum.com/t/why-is-my-random-number-lookup-slow-using-lists/27970)

<div class="topic-metadata">

**Author:** [@oegma2](https://forum.elixirforum.com/u/oegma2)\
**Replies:** 9\
**Last updated:** [January 5, 2020, 8:50pm UTC](https://forum.elixirforum.com/t/why-is-my-random-number-lookup-slow-using-lists/27970 "2020-01-05T20:50:32Z")

</div>

Hi, I am new to Elixir world and still have a long way to go, but starting with a basic problem I’ve been using to learn any new language - one with monkies hitting random keys and see if they can write a chapter out of …

---

## [Looping list and add to tuple](https://forum.elixirforum.com/t/looping-list-and-add-to-tuple/22758)

<div class="topic-metadata">

**Author:** [@shahryarjb](https://forum.elixirforum.com/u/shahryarjb)\
**Replies:** 9\
**Last updated:** [May 29, 2019, 10:57am UTC](https://forum.elixirforum.com/t/looping-list-and-add-to-tuple/22758 "2019-05-29T10:57:07Z")

</div>

Hello, I have a list and want to move it to map or tuple or I have a 3 map records of Repo.all, then after editing this record I want to save these to a map \[a, b, c\] |\> Enum.map(fn item -\> item + 1 end) now I need to …

---

## [Sending ok/error-tuples to the frontend - what do you use and why?](https://forum.elixirforum.com/t/sending-ok-error-tuples-to-the-frontend-what-do-you-use-and-why/17876)

<div class="topic-metadata">

**Author:** [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Replies:** 17\
**Last updated:** [November 21, 2018, 7:01pm UTC](https://forum.elixirforum.com/t/sending-ok-error-tuples-to-the-frontend-what-do-you-use-and-why/17876 "2018-11-21T19:01:34Z")

</div>

Recently on the Elm forums, a discussion about Union Types and how they are represented in other languages was started. After telling them about the {:ok, value} | {:error, error\_message} ‘type’ that sees frequent use i…

---

## [Question marks and tuple returns?](https://forum.elixirforum.com/t/question-marks-and-tuple-returns/15930)

<div class="topic-metadata">

**Author:** [@Ordermind](https://forum.elixirforum.com/u/Ordermind)\
**Replies:** 2\
**Last updated:** [August 18, 2018, 1:47pm UTC](https://forum.elixirforum.com/t/question-marks-and-tuple-returns/15930 "2018-08-18T13:47:20Z")

</div>

Hi, a quick question regarding naming conventions. If I have a function that returns a tuple with status and a boolean, should I still use a question mark at the end of the function name, or should that only be used for …

---

## [Display custom error message in proper format](https://forum.elixirforum.com/t/display-custom-error-message-in-proper-format/14366)

<div class="topic-metadata">

**Author:** [@script](https://forum.elixirforum.com/u/script)\
**Replies:** 2\
**Last updated:** [May 25, 2018, 4:43am UTC](https://forum.elixirforum.com/t/display-custom-error-message-in-proper-format/14366 "2018-05-25T04:43:30Z")

</div>

I have a list of values like this result = \[:id, :title, :id\] I am using comprehensions to iterate over them and display the error message which looks like this: for n \<- result, do: {n, "field doesn't exist"} …

---

## [Organization and implementation of Elixir](https://forum.elixirforum.com/t/organization-and-implementation-of-elixir/13814)

<div class="topic-metadata">

**Author:** [@ijverig](https://forum.elixirforum.com/u/ijverig)\
**Replies:** 3\
**Last updated:** [April 23, 2018, 2:22pm UTC](https://forum.elixirforum.com/t/organization-and-implementation-of-elixir/13814 "2018-04-23T14:22:03Z")

</div>

My question is regarding the implementation of the language: In Erlang we have element to access tuple elements, setelement to change elements, append\_element to append elements to tuples, and so on… In Elixir we have e…
