In most cases `:infinity` is treated as an pos-integer-like value (timeouts
etc.)

While dealing with long collections (lists) one might be interested in the
user-configured length of the collection head to return. This might happen
when the collection has been previously ordered and the tail is of
lesser value compared to the head.

In such cases I find myself writing

```
|> then(fn
  {collection, :infinity} -> collection
  {collection, n} when is_integer(n) -> Enum.take(collection, n)
end)
```

I think making `Enum.take/2` to accept `:infinity` as the second argument
would bring no harm. It could simply return back the `Enumerable.t()`.

WDYT? I am all in for providing a PR if accepted.

--
AM

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAJ9Hrjb2rPYb4o93RYUKyPHs_w_KJrA-7aai5vSzoPugUG9A4g%40mail.gmail.com.

Reply via email to