Hi Rudolf. Elixir actually has such wrapper already, and what's more cool about 
it, it's implemented exactly how you suggested:
https://github.com/elixir-lang/elixir/blob/a64d42f5d3cb6c32752af9d3312897e8cd5bb7ec/lib/elixir/lib/kernel.ex#L1724

Other tuple related functions are mentioned at the top of Tuple module docs.

-------- Original Message --------
On 10 Jun 2022, 22:25, Rudolf Manusadzhian wrote:

> Hi there. Recently I faced the situation where I wanted to "replace" the 
> element of a tuple that was created dynamically from a list with the length 
> defined at runtime.
>
> While I found [:erlang.setelement(index, tuple, 
> value)](https://www.erlang.org/docs/19/man/erlang.html#setelement-3)does what 
> I need, its arguments order and 1-based indexes are not that natural to 
> elixir.
>
> So I would propose to add a wrapper around :erlang.setelement/3to Tuple 
> module. (I called itreplace_atjust because I was looking for the analogy 
> ofList.replace_atbut for tuple)
>
> I put together quickly a commit of how it could be implemented 
> https://github.com/elixir-lang/elixir/commit/6e498edaf257e3fccf15bc5243c3ccf2d67e6e85
>
> --
> 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/58227783-b0bf-4d0f-b1cb-df15f4df0f97n%40googlegroups.com](https://groups.google.com/d/msgid/elixir-lang-core/58227783-b0bf-4d0f-b1cb-df15f4df0f97n%40googlegroups.com?utm_medium=email&utm_source=footer).

-- 
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/7TIjJ64aoveoBGfH4Bl4ZXlNF8UB2RYAQEBR89Z6mPwrwyaQAU8pFmPAI_bVtW37uW9M-dQPXESOr_t8htW3IsKQ0OQciRzlD2EQjeciVsw%3D%40pm.me.

Reply via email to