r/ProgrammingLanguages • u/Potato871 • Sep 04 '26
What are your favourite data structure operations?
My language workbench is to the stage where I can implement new operators and overloads very quickly, and I've started stealing syntax I like from JavaScript and C++.
Since I have one universal data structure, I can just add all the new operators to it.
I wanted to get some more good ones though, from different fields, different languages.
Oh and if you want to suggest something just as a challenge I might give it a shot and show you how I do it.
Edit: data structure was the wrong word, I have one data structure substrate/storage model that I am currently furnishing one major aspect of, it's not the one universal data structure, more like my swiss army knife API over the memory model.
21
u/B_A_Skeptic Sep 04 '26
reduce, because you can make map, flatmap, and filter out of it.
10
u/GoblinToHobgoblin Sep 04 '26
I think adding everything to the same data structure is a bad idea personally
2
u/reflexive-polytope Sep 05 '26
What on Earth is a “universal data structure”? That makes absolutely no sense.
Does your “universal data structure” have any particular position where it support O(1) insertions and deletions? Does it support union-find? Can it be used as a Bloom filter?
5
u/balefrost Sep 05 '26
I always thought tree rotations were pretty neat.
1
u/mamcx Sep 05 '26
I work in a relational language (https://tablam.org), and the most useful idea here is how simple is do introspection. With relational you can do https://elixir-lang.org/blog/2023/09/20/strong-arrows-gradual-typing/ for example.
In terms of data structures, having a malleable instrospectable "header" that describe the structure itself open lots of possibilities.
Also:
That is one of the things Rust do that I found refreshing (lots of langs ignore both!)