[elixir-core:8471] Re: [Proposal] Add invert() method to Map module

2019-02-06 Thread Ben Wilson
Map.invert is at least largely harmless, unlike some of the other proposals that happen. It's still a little odd to me to have a function that boils down to just: Map.new(map, fn {k, v} -> {v, k} end) Honestly that is almost clearer if you've never heard the word "invert" with respect to

Re: [elixir-core:8470] [Proposal] Add invert() method to Map module

2019-02-06 Thread Justin Gamble
Thanks for your feedback Amos. I hope you can appreciate that not all applications are focused primarily around performance. If performance is key to your application, then you are responsible for learning tricks to optimize the code. That might include iterating over your map a single time,

Re: [elixir-core:8468] [Proposal] Add invert() method to Map module

2019-02-06 Thread Glauber Campinho
Hi, I would also raise the concern that map has no ordering, so inverting a map can have different results depending on the map. Said that, I believe that inverting should be done case by case and should not be in the core, and if it is, it should solve the problem of sorting or throw an error.

Re: [elixir-core:8467] [Proposal] Add invert() method to Map module

2019-02-06 Thread Amos King - Binary Noggin
I find that small piece of code would often have other data processing connected to it. I'd hate to cycle through the map multiple times if I was going to swap the key and value, and then do more processing on the value. I think such a function would encourage the practice of chaining along