Skip to content

Commit 49aed8c

Browse files
author
José Valim
committed
Make a distinction about eager and full evaluation of the collection
1 parent 366d984 commit 49aed8c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/elixir/lib/enum.ex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ defmodule Enum do
6666
iex> Enum.map(dict, fn { k, v } -> { k, v * 2 } end)
6767
[a: 2, b: 4]
6868
69-
Note that the `Enum` module is eager: it always evaluates the whole collection
70-
and returns a list as result. The `Stream` module allows lazy enumeration of
71-
collections and also provides infinite streams. Infinite streams needs to be
72-
carefully used with `Enum` functions as they can potentially run forever, for
73-
example:
69+
Note the functions in the `Enum` module are eager: they always start
70+
the enumeration of the given collection. The `Stream` module allows
71+
lazy enumeration of collections and also provides infinite streams.
72+
73+
Since the majority of the functions in `Enum` enumerate the whole
74+
collection and return a list as result, infinite streams need to
75+
be carefully used with such functions, as they can potentially run
76+
forever, for example:
7477
7578
Enum.each Stream.cycle([1,2,3]), &IO.puts(&1)
7679

0 commit comments

Comments
 (0)