# \#data-structures

**URL:** https://forum.elixirforum.com/tag/data-structures/40.md

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

---

## [EEP-79 native records and structs](https://forum.elixirforum.com/t/eep-79-native-records-and-structs/75022)

<div class="topic-metadata">

**Author:** [@cevado](https://forum.elixirforum.com/u/cevado)\
**Replies:** 13\
**Last updated:** [April 15, 2026, 11:36pm UTC](https://forum.elixirforum.com/t/eep-79-native-records-and-structs/75022 "2026-04-15T23:36:13Z")

</div>

I was reading the EEP-79, and thinking about the poor record support in Elixir(i’ve tried to discuss about that in the forum before). I see 2 clear advantages of native-records over structs, mainly it being a enforced na…

---

## [Draft - enforce typed structs and validation rules with draft schema](https://forum.elixirforum.com/t/draft-enforce-typed-structs-and-validation-rules-with-draft-schema/74631)

<div class="topic-metadata">

**Author:** [@2p4b](https://forum.elixirforum.com/u/2p4b)\
**Replies:** 2\
**Last updated:** [March 25, 2026, 6:17am UTC](https://forum.elixirforum.com/t/draft-enforce-typed-structs-and-validation-rules-with-draft-schema/74631 "2026-03-25T06:17:08Z")

</div>

Define typed structs with built-in validation. Draft allows developers to describe the structure of data and enforce constraints when constructing structs, helping ensure that invalid data never enters your domain. Inst…

---

## [ExSift - High-performance MongoDB-style query filtering for Elixir](https://forum.elixirforum.com/t/exsift-high-performance-mongodb-style-query-filtering-for-elixir/73417)

<div class="topic-metadata">

**Author:** [@cheekyfinder](https://forum.elixirforum.com/u/cheekyfinder)\
**Replies:** 1\
**Last updated:** [November 24, 2025, 7:21am UTC](https://forum.elixirforum.com/t/exsift-high-performance-mongodb-style-query-filtering-for-elixir/73417 "2025-11-24T07:21:09Z")

</div>

ExSift: High-performance MongoDB-style query filtering for Elixir I’m working on ExSift, a high-performance library that uses sift.js-inspired MongoDB-style query syntax to filter Elixir collections. What is it? ExSift …

---

## [Efficient way to perform vector dot product](https://forum.elixirforum.com/t/efficient-way-to-perform-vector-dot-product/25313)

<div class="topic-metadata">

**Author:** [@steven7](https://forum.elixirforum.com/u/steven7)\
**Replies:** 33\
**Last updated:** [September 18, 2025, 5:59pm UTC](https://forum.elixirforum.com/t/efficient-way-to-perform-vector-dot-product/25313 "2025-09-18T17:59:51Z")

</div>

Hi I recently have the requirement to perform dot-product on two vectors in Elixir and I was wondering what would be the most efficient way. Imagine the following scenario, Say I have ~1M vectors stored in memory, each …

---

## [Using a struct within a struct produces errors](https://forum.elixirforum.com/t/using-a-struct-within-a-struct-produces-errors/71058)

<div class="topic-metadata">

**Author:** [@Ookma-Kyi](https://forum.elixirforum.com/u/Ookma-Kyi)\
**Replies:** 14\
**Last updated:** [May 30, 2025, 12:36am UTC](https://forum.elixirforum.com/t/using-a-struct-within-a-struct-produces-errors/71058 "2025-05-30T00:36:24Z")

</div>

I have the following code: defmodule Servy.Conv do defstruct method: "", path: "", resp\_body: "", status: nil def full\_status(conv) do "#{conv.status} #{status\_reason(conv.status)}" end defp status\_reason(…

---

## [Tests as First-Class Citizens](https://forum.elixirforum.com/t/tests-as-first-class-citizens/70871)

<div class="topic-metadata">

**Author:** [@mudasobwa](https://forum.elixirforum.com/u/mudasobwa)\
**Replies:** 0\
**Last updated:** [May 14, 2025, 12:30pm UTC](https://forum.elixirforum.com/t/tests-as-first-class-citizens/70871 "2025-05-14T12:30:14Z")

</div>

---

## [Trees of data in Elixir](https://forum.elixirforum.com/t/trees-of-data-in-elixir/4489)

<div class="topic-metadata">

**Author:** [@thorsten-michael](https://forum.elixirforum.com/u/thorsten-michael)\
**Replies:** 9\
**Last updated:** [April 30, 2025, 6:48pm UTC](https://forum.elixirforum.com/t/trees-of-data-in-elixir/4489 "2025-04-30T18:48:11Z")

</div>

What is the idomatic way to process tree data structures in Elixir? I have a database table that holds a ton of rows which define a hierarchy by an attribute called parent\_id. Solution 1: Huge Map A Tree module that …

---

## [Looking for / building a generic tree data structure library](https://forum.elixirforum.com/t/looking-for-building-a-generic-tree-data-structure-library/64232)

<div class="topic-metadata">

**Author:** [@sschuldenzucker](https://forum.elixirforum.com/u/sschuldenzucker)\
**Replies:** 5\
**Last updated:** [April 30, 2025, 6:46pm UTC](https://forum.elixirforum.com/t/looking-for-building-a-generic-tree-data-structure-library/64232 "2025-04-30T18:46:49Z")

</div>

Hey all, I’m building my own little app (side project) and I’m looking for a tree data structure. I’m honestly wondering if I’m overlooking something but I couldn’t find a library that’s right for me. The whole thing sh…

---

## [Solving the 99 Elixir Problems - Join Me on My Journey!](https://forum.elixirforum.com/t/solving-the-99-elixir-problems-join-me-on-my-journey/68826)

<div class="topic-metadata">

**Author:** [@ouerghi01](https://forum.elixirforum.com/u/ouerghi01)\
**Replies:** 0\
**Last updated:** [January 19, 2025, 2:46pm UTC](https://forum.elixirforum.com/t/solving-the-99-elixir-problems-join-me-on-my-journey/68826 "2025-01-19T14:46:59Z")

</div>

Hi everyone! I’ve started a project to solve the 99 functional programming problems in Elixir, and I’d love to share it with the community. You can find the repository here: Elixir-99-Functional-Mastery This is a grea…

---

## [Need to display resources in the exact order they are declared - ordered Map?](https://forum.elixirforum.com/t/need-to-display-resources-in-the-exact-order-they-are-declared-ordered-map/67829)

<div class="topic-metadata">

**Author:** [@James\_E](https://forum.elixirforum.com/u/James_E)\
**Replies:** 4\
**Last updated:** [December 2, 2024, 9:24pm UTC](https://forum.elixirforum.com/t/need-to-display-resources-in-the-exact-order-they-are-declared-ordered-map/67829 "2024-12-02T21:24:56Z")

</div>

I’m working on a program that needs to display the status of several resources. The dashboard needs to consistently display these resources in the exact order the resources are declared in a config file. Right now, I’m …

---

## [How to swap elements in a list?](https://forum.elixirforum.com/t/how-to-swap-elements-in-a-list/34471)

<div class="topic-metadata">

**Author:** [@sarat1669](https://forum.elixirforum.com/u/sarat1669)\
**Replies:** 10\
**Last updated:** [November 23, 2024, 11:56pm UTC](https://forum.elixirforum.com/t/how-to-swap-elements-in-a-list/34471 "2024-11-23T23:56:06Z")

</div>

Is there a better way to swap elements in a list? Any inbuilt function or a library? defmodule SwapElements do def swap(list, first\_index, second\_index) do {a, b} = split(list, first\_index + 1) {x, y} = split…

---

## [RangeSet - library for handling range sets/non-continuous ranges](https://forum.elixirforum.com/t/rangeset-library-for-handling-range-sets-non-continuous-ranges/65639)

<div class="topic-metadata">

**Author:** [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Replies:** 0\
**Last updated:** [August 23, 2024, 8:01am UTC](https://forum.elixirforum.com/t/rangeset-library-for-handling-range-sets-non-continuous-ranges/65639 "2024-08-23T08:01:28Z")

</div>

I created it during one of AoCs, but finally I have polished it enough to publish it. Nothing fancy, just basic set operations: intersection difference union It implements Enumerable, so you can traverse whole set wit…

---

## [Arrays - Fast and versatile arrays with swappable implementations](https://forum.elixirforum.com/t/arrays-fast-and-versatile-arrays-with-swappable-implementations/42146)

<div class="topic-metadata">

**Author:** [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Replies:** 14\
**Last updated:** [July 19, 2024, 11:59am UTC](https://forum.elixirforum.com/t/arrays-fast-and-versatile-arrays-with-swappable-implementations/42146 "2024-07-19T11:59:38Z")

</div>

While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Elixir for certain situations. However, so far a stable and idiomatic array library wa…

---

## [Name for maybe-reversed lists?](https://forum.elixirforum.com/t/name-for-maybe-reversed-lists/63505)

<div class="topic-metadata">

**Author:** [@brettbeatty](https://forum.elixirforum.com/u/brettbeatty)\
**Replies:** 2\
**Last updated:** [May 12, 2024, 5:05pm UTC](https://forum.elixirforum.com/t/name-for-maybe-reversed-lists/63505 "2024-05-12T17:05:46Z")

</div>

Many of the higher order functions in Enum reduce a list (or other enumerable) into another, reversed list then reverse it back to the original order. When several of these functions are chained together, the list is rev…

---

## [Is it possible to define structs at runtime](https://forum.elixirforum.com/t/is-it-possible-to-define-structs-at-runtime/62537)

<div class="topic-metadata">

**Author:** [@chazwatkins](https://forum.elixirforum.com/u/chazwatkins)\
**Replies:** 14\
**Last updated:** [April 4, 2024, 1:53pm UTC](https://forum.elixirforum.com/t/is-it-possible-to-define-structs-at-runtime/62537 "2024-04-04T13:53:01Z")

</div>

I’m considering writing an integration with Salesforce. Salesforce has SObjects of various types like Case, Quote, Lead, CustomObject\_\_c, etc. These SObjects are like database tables with their own schemas. I’d like t…

---

## [Preferred data representation(s) for property graphs?](https://forum.elixirforum.com/t/preferred-data-representation-s-for-property-graphs/57617)

<div class="topic-metadata">

**Author:** [@Rich\_Morin](https://forum.elixirforum.com/u/Rich_Morin)\
**Replies:** 4\
**Last updated:** [August 14, 2023, 9:23pm UTC](https://forum.elixirforum.com/t/preferred-data-representation-s-for-property-graphs/57617 "2023-08-14T21:23:46Z")

</div>

I have a (very WIP) project that will be making some graph-structured data generally available. I’d really like it to be accessible and convenient for AI systems (e.g., LLMs) and their developers. So, I’d like to know wh…

---

## [Term container supporting \`push(term)\` and \`get\_last\_100()\`](https://forum.elixirforum.com/t/term-container-supporting-push-term-and-get-last-100/56688)

<div class="topic-metadata">

**Author:** [@odohMei7](https://forum.elixirforum.com/u/odohMei7)\
**Replies:** 4\
**Last updated:** [June 25, 2023, 4:11pm UTC](https://forum.elixirforum.com/t/term-container-supporting-push-term-and-get-last-100/56688 "2023-06-25T16:11:36Z")

</div>

Is there an easy to use ordered data structure that supports a push operation to add some term and an operation to fetch the last 100 (or n) pushed terms such that old values are discarded (a bit in the spirit of a cycli…

---

## [How do I design data structures with multiple join tables?](https://forum.elixirforum.com/t/how-do-i-design-data-structures-with-multiple-join-tables/55687)

<div class="topic-metadata">

**Author:** [@aNerdInTheHand](https://forum.elixirforum.com/u/aNerdInTheHand)\
**Replies:** 7\
**Last updated:** [May 11, 2023, 9:53am UTC](https://forum.elixirforum.com/t/how-do-i-design-data-structures-with-multiple-join-tables/55687 "2023-05-11T09:53:22Z")

</div>

Hi all, I’m learning Phoenix and building an application that creates musical chord progressions, but my relational data skills are a bit rusty (see my previous question). I may not have phrased this question very well …

---

## [Is there a data structure that has O(1) complexity for value-\>key lookups?](https://forum.elixirforum.com/t/is-there-a-data-structure-that-has-o-1-complexity-for-value-key-lookups/55241)

<div class="topic-metadata">

**Author:** [@l1x](https://forum.elixirforum.com/u/l1x)\
**Replies:** 1\
**Last updated:** [April 13, 2023, 8:08am UTC](https://forum.elixirforum.com/t/is-there-a-data-structure-that-has-o-1-complexity-for-value-key-lookups/55241 "2023-04-13T08:08:57Z")

</div>

I was wondering if there is a data structure (probably similar to Map) that has a O(1) complexity both ways. key → value is covered by fetch but value-\> key is not.

---

## [ExRoseTree - a Rose Tree and Zipper in Elixir with a slew of navigation primitives](https://forum.elixirforum.com/t/exrosetree-a-rose-tree-and-zipper-in-elixir-with-a-slew-of-navigation-primitives/54520)

<div class="topic-metadata">

**Author:** [@StoatPower](https://forum.elixirforum.com/u/StoatPower)\
**Replies:** 2\
**Last updated:** [March 12, 2023, 9:42pm UTC](https://forum.elixirforum.com/t/exrosetree-a-rose-tree-and-zipper-in-elixir-with-a-slew-of-navigation-primitives/54520 "2023-03-12T21:42:09Z")

</div>

Hello everyone, I’m excited to announce the release of ExRoseTree, a Rose Tree and Zipper in Elixir with a slew of navigation primitives and traversal functions. This project began as a generic exploration in designing…

---

## [Handling different Joken error messages with json()](https://forum.elixirforum.com/t/handling-different-joken-error-messages-with-json/53770)

<div class="topic-metadata">

**Author:** [@ghenry](https://forum.elixirforum.com/u/ghenry)\
**Replies:** 5\
**Last updated:** [February 8, 2023, 10:14pm UTC](https://forum.elixirforum.com/t/handling-different-joken-error-messages-with-json/53770 "2023-02-08T22:14:06Z")

</div>

Hi all, A beginner here. I have the following plug code from an example Auth0 repo: def call(conn, \_default) do with {:ok, token} when is\_binary(token) \<- get\_token(conn), {:ok, claims} \<- Token.verify\_an…

---

## [Value of event sourcing?](https://forum.elixirforum.com/t/value-of-event-sourcing/52852)

<div class="topic-metadata">

**Author:** [@jdumont](https://forum.elixirforum.com/u/jdumont)\
**Replies:** 3\
**Last updated:** [December 31, 2022, 6:25am UTC](https://forum.elixirforum.com/t/value-of-event-sourcing/52852 "2022-12-31T06:25:43Z")

</div>

So…I’m back in front of a text editor (and not behind a camera) and this cropped up just as I logged into the forum again after — checks calendar — a solid 18 months away! I’ve switched careers but still plan to do some …

---

## [Is it possible to implement all known algos within elixir?](https://forum.elixirforum.com/t/is-it-possible-to-implement-all-known-algos-within-elixir/51817)

<div class="topic-metadata">

**Author:** [@newton-peixoto](https://forum.elixirforum.com/u/newton-peixoto)\
**Replies:** 7\
**Last updated:** [November 15, 2022, 11:39pm UTC](https://forum.elixirforum.com/t/is-it-possible-to-implement-all-known-algos-within-elixir/51817 "2022-11-15T23:39:26Z")

</div>

Hello everyone, I’d like to know if is possible to execute all “populary known” algorithms in elixir. I’m asking that because most of algorithms use arrays for example and as far as I known elixir does not implement thos…

---

## [Shaping flat maps into nested maps with changing data inputs](https://forum.elixirforum.com/t/shaping-flat-maps-into-nested-maps-with-changing-data-inputs/50871)

<div class="topic-metadata">

**Author:** [@dharmaraja](https://forum.elixirforum.com/u/dharmaraja)\
**Replies:** 6\
**Last updated:** [October 9, 2022, 10:59am UTC](https://forum.elixirforum.com/t/shaping-flat-maps-into-nested-maps-with-changing-data-inputs/50871 "2022-10-09T10:59:05Z")

</div>

I am working to shape request parameters that are flat into nested maps to work with changesets in Ecto. The intention is to only update the rows based on the keys passed on the parameters so when some keys are absent it…

---

## [Audit - a library to track changes to in-memory data structures](https://forum.elixirforum.com/t/audit-a-library-to-track-changes-to-in-memory-data-structures/50124)

<div class="topic-metadata">

**Author:** [@rugyoga](https://forum.elixirforum.com/u/rugyoga)\
**Replies:** 0\
**Last updated:** [September 7, 2022, 9:53pm UTC](https://forum.elixirforum.com/t/audit-a-library-to-track-changes-to-in-memory-data-structures/50124 "2022-09-07T21:53:53Z")

</div>

Ever have to wrangle large in-memory data structures and wonder which code changes corresponded to which data structure changes? Well I have a library for you… https://medium.com/building-lob/tracking-changes-in-your-el…

---

## [Struct pretty printing through defimpl Inspect](https://forum.elixirforum.com/t/struct-pretty-printing-through-defimpl-inspect/49732)

<div class="topic-metadata">

**Author:** [@RooSoft](https://forum.elixirforum.com/u/RooSoft)\
**Replies:** 2\
**Last updated:** [August 23, 2022, 3:22pm UTC](https://forum.elixirforum.com/t/struct-pretty-printing-through-defimpl-inspect/49732 "2022-08-23T15:22:22Z")

</div>

The goal is to make sure a struct is printed in a human readable format when sent to IO.inspect. This is new to me, but I found it’s apparently possible to use defimpl to achieve that… here is what I am attempting defi…

---

## [Elixir Map vs Erlang :array](https://forum.elixirforum.com/t/elixir-map-vs-erlang-array/47977)

<div class="topic-metadata">

**Author:** [@stevensonmt](https://forum.elixirforum.com/u/stevensonmt)\
**Replies:** 4\
**Last updated:** [May 25, 2022, 7:02pm UTC](https://forum.elixirforum.com/t/elixir-map-vs-erlang-array/47977 "2022-05-25T19:02:30Z")

</div>

It appears that the Elixir Map implementation is mostly an ergonomic wrapper for :maps in Erlang. In many graph/network exercises I’ve been faced with the need to convert a structure of List of Lists to something accessi…

---

## [Efficient data structure similar to maxHeap](https://forum.elixirforum.com/t/efficient-data-structure-similar-to-maxheap/47118)

<div class="topic-metadata">

**Author:** [@stevensonmt](https://forum.elixirforum.com/u/stevensonmt)\
**Replies:** 0\
**Last updated:** [April 8, 2022, 11:07pm UTC](https://forum.elixirforum.com/t/efficient-data-structure-similar-to-maxheap/47118 "2022-04-08T23:07:57Z")

</div>

The genesis of my question is this problem from Leetcode. I want a data structure that keeps values sorted without iterating over the whole structure on each update. I thought using a gb\_tree would do the trick, but the…

---

## [Put/update deep inside nested maps (and auto-create intermediate keys)](https://forum.elixirforum.com/t/put-update-deep-inside-nested-maps-and-auto-create-intermediate-keys/7993)

<div class="topic-metadata">

**Author:** [@skosch](https://forum.elixirforum.com/u/skosch)\
**Replies:** 11\
**Last updated:** [February 7, 2022, 9:38pm UTC](https://forum.elixirforum.com/t/put-update-deep-inside-nested-maps-and-auto-create-intermediate-keys/7993 "2022-02-07T21:38:33Z")

</div>

To my knowledge, put\_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for example, put\_in(%{a: %{}}, \[:a, :b, :c\], 42) will fail). But – despite all the risks –…

---

## [From many to one to many to many with data on the join table](https://forum.elixirforum.com/t/from-many-to-one-to-many-to-many-with-data-on-the-join-table/45563)

<div class="topic-metadata">

**Author:** [@benonymus](https://forum.elixirforum.com/u/benonymus)\
**Replies:** 0\
**Last updated:** [January 27, 2022, 9:17am UTC](https://forum.elixirforum.com/t/from-many-to-one-to-many-to-many-with-data-on-the-join-table/45563 "2022-01-27T09:17:33Z")

</div>

Hey, I am transitioning a many to one relation to a many to many. We have a users and a teams schema at the moment. And we want to allow users to join multiple teams, instead of the currently allowed one. I am thinking…

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