Re: [elixir-core:10841] [Proposal] Introduce `last` and `init` functions to Kernel

2022-03-24 Thread 'eksperimental' via elixir-lang-core
We already have List.last/1-2 On Thu, 24 Mar 2022 06:24:24 -0700 (PDT) Weslei Juan Novaes Pereira wrote: > As Elixir has the `hd` and `tl` functions, it'd be very useful to > have a `init` and `last` functions as well. For example: > > last: takes a list and returns its last element. > iex>

[elixir-core:10841] [Proposal] Introduce `last` and `init` functions to Kernel

2022-03-24 Thread Weslei Juan Novaes Pereira
As Elixir has the `hd` and `tl` functions, it'd be very useful to have a `init` and `last` functions as well. For example: last: takes a list and returns its last element. iex> last [5,4,3,2,1] 1 init: takes a list and returns everything except its last element. iex> init [5,4,3,2,1] [5,4,3,2]