[elixir-core:10915] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread Randson
Currently, the function `List.delete` only works for a single field. What I want to add is the possibility to delete multiple fields by passing a list of fields I want to remove. Can be like this one: ```elixir List.delete([:a, :b, :c, :d, :e], [:a, :b]) #=> [:c, :d, :e] ``` Or, it can be a ne

Re: [elixir-core:10915] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread 'Andrey Yugai' via elixir-lang-core
Hey Randson, have you seen `Enum.filter`? It does almost exactly what you want, except for any enumerable, not just list. Original Message On 7 Jun 2022, 18:31, Randson < orand...@gmail.com> wrote: Currently, the function `List.delete` only works for a single field. What I wa

RE: [elixir-core:10916] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread Randson Oliveira
Nice, thanks for the heads up.  Yep, it works exactly the way I want. However, it would be nice to have that pattern matching option. Without having to call the Enum module. But yeah, if you guys think just using `Enum.filter` is enough. I’m okay. Thanks,Randson From: 'Andrey Yugai' via elixir-lang

Re: [elixir-core:10917] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread 'Andrey Yugai' via elixir-lang-core
>From the top of the head I can think of `Enum/Stream.chunk_every(list, n, 1) >|> Enum.filter(...)` to delete matching sequences of length n. Perhaps there's >better data structure choice in your particular case. Original Message On 7 Jun 2022, 18:41, Randson Oliveira < orand.

Re: [elixir-core:10918] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread Zach Daniel
You wouldn't be able to pattern match on the input being a list regardless because you could have a list of lists and be wanting to delete one of those lists. For example: ```elixir List.delete([[:a, :b], [:c, :d]], [:a, :b]) #=> [[:c, :d]] ``` And I generally agree with others that the Enum

Re: [elixir-core:10919] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread Wojtek Mach
The --/2 operator already does this. :) iex(1)> [:a, :b, :c, :d, :e] -- [:a, :b] [:c, :d, :e] > On 7 Jun 2022, at 17:31, Randson wrote: > > Currently, the function `List.delete` only works for a single field. What I > want to add is the possibility to delete multiple fields by passing a list

Re: [elixir-core:10920] [Proposal] List.delete support for delete multiple fields inside a list

2022-06-07 Thread Zach Daniel
The `--` operator has an important difference in behavior from Enum.filter/reject, though. [:a, :a, :a] -- [:a] [:a, :a] On Tue, Jun 07, 2022 at 1:30 PM, Wojtek Mach < woj...@wojtekmach.pl > wrote: > > The  --/2 operator already does this. :) > > > iex(1)> [:a, :b, :c, :d, :e] -- [:a, :b] >