Re: [elixir-core:8358] [Proposal] Add function Kernel.delete_in/2

2018-10-27 Thread José Valim
Hi Jonathan,

We had this discussion when we added pop_in/2. The reason why we choose
pop_in/2 is because it provides more features than delete_in on its own and
we want to avoid overloading Kernel with too many functions. If your
concern is chaining, you can always perform a |> elem(1) after popping.

Thanks for the proposal!

*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R


On Sat, Oct 27, 2018 at 7:51 PM Jonathan Arnett 
wrote:

> It would be useful to have a function that uses the Access protocol to
> delete elements within nested data structures. This is similar in concept
> to Kernel.pop_in/2 , but
> Kernel.delete_in/2 should just return the data structure without the
> specified element, whereas Kernel.pop_in/2 returns a tuple whose first
> element is the removed value and second element is the data structure
> without the specified element. The return structure of
> Kernel.delete_in/2 would allow it to be more easily chained than
> Kernel.pop_in/2.
>
> Expected behavior
> Kernel.delete_in(%{foo: "bar", baz: "qux"}, [:foo])
> #=> %{baz: "qux"}
>
> Kernel.delete_in(%{foo: %{bar: "baz", qux: "quux"}}, [:foo, :qux])
> #=> %{foo: %{bar: "baz"}}
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/85369f10-5234-4c75-a282-cd644e380a0b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BKyxLTHMxZX8Pihq57ms2r-N7f4WBSEU7A%2BZb4Vg4zpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:8357] [Proposal] Add function Kernel.delete_in/2

2018-10-27 Thread Louis Pilfold
Hey

How would it know how to delete a value from the given data structure? The
Access protocol could be implemented for any term.

Cheers,
Louis

On Sat, 27 Oct 2018, 18:51 Jonathan Arnett,  wrote:

> It would be useful to have a function that uses the Access protocol to
> delete elements within nested data structures. This is similar in concept
> to Kernel.pop_in/2 , but
> Kernel.delete_in/2 should just return the data structure without the
> specified element, whereas Kernel.pop_in/2 returns a tuple whose first
> element is the removed value and second element is the data structure
> without the specified element. The return structure of
> Kernel.delete_in/2 would allow it to be more easily chained than
> Kernel.pop_in/2.
>
> Expected behavior
> Kernel.delete_in(%{foo: "bar", baz: "qux"}, [:foo])
> #=> %{baz: "qux"}
>
> Kernel.delete_in(%{foo: %{bar: "baz", qux: "quux"}}, [:foo, :qux])
> #=> %{foo: %{bar: "baz"}}
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/85369f10-5234-4c75-a282-cd644e380a0b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CABu8xFAJNsR4p0PHSLqn%3D5Y%2Bwj9v7uBD%2BeZzetxUAKErpXW-EQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[elixir-core:8357] [Proposal] Add function Kernel.delete_in/2

2018-10-27 Thread Jonathan Arnett
It would be useful to have a function that uses the Access protocol to 
delete elements within nested data structures. This is similar in concept 
to Kernel.pop_in/2 , but 
Kernel.delete_in/2 should just return the data structure without the 
specified element, whereas Kernel.pop_in/2 returns a tuple whose first 
element is the removed value and second element is the data structure 
without the specified element. The return structure of 
Kernel.delete_in/2 would allow it to be more easily chained than 
Kernel.pop_in/2.

Expected behavior
Kernel.delete_in(%{foo: "bar", baz: "qux"}, [:foo])
#=> %{baz: "qux"}

Kernel.delete_in(%{foo: %{bar: "baz", qux: "quux"}}, [:foo, :qux])
#=> %{foo: %{bar: "baz"}}


-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/85369f10-5234-4c75-a282-cd644e380a0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.