docjazither

docjazither

Delete the 1st pair in a map

Hi OGs,
How can I delete the 1st pair in a map ?
Thank you

Most Liked

sodapopcan

sodapopcan

OP doesn’t seem to care that they are out of order but I’m dying to know the use-case :joy:

adamu

adamu

Please post your code showing how your map is constructed. As @msimonborg said, there is no such concept of the “first” item in a map.

jhogberg

jhogberg

Erlang Core Team

If you don’t specifically need a map, consider using :gb_trees instead. Its take_smallest/1 and take_largest/1 operations are bound to be quicker than converting to list, sorting, deleting the first entry, and then creating a map again.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Yeah this whole exchange is kind of wild.

@docjazither just in case this isn’t abundantly clear: What you’re doing is deleting a random (ish) key from the map. If that’s OK with you then proceed. If it isn’t, please answer one of the several people who asked you to clarify what “first” means to you.

BartOtten

BartOtten

If you want the internet to respont, make an error - Elvis Presley :sweat_smile:

ps. quoting the brilliant and definitive answer, rewriting it using Enum.map/2 so you can say it’s wrong… it is Lousy. Jea Lousy. How would you feel if you liked a post and the author edited it and blamed you for something you did not?

Tag: satire

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement