[Proposal] Add :infinity to Enum.take and Stream.take

46 views
Skip to first unread message

Daniel Kukula

unread,
Dec 9, 2023, 7:41:21 AM12/9/23
to elixir-lang-core
We currently use infinity in multiple places in the standard library, it become a defacto standard in the ecosystem. I think that when passing :infinity to enumerable.take this should make it a noop.
Example: list |> Enum.take(:infinity) would return the same list.
I'm working on a custom inspect function and I see that limit is either an integer or :infinity. I'm currently using Stream module to process the inspected value to pretty print it and I need conditionally add logic to handle infinity.

Aleksei Matiushkin

unread,
Dec 9, 2023, 8:39:20 AM12/9/23
to elixir-l...@googlegroups.com
Use `Enum.to_list/1`, it does exactly this.

--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/73ee72bf-3c7e-489d-a98c-a1b22fa7cd5an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages