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
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
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
>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.
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
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
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]
>