Skip to content

Commit

Permalink
Merge pull request #42 from j0urneyK/fix-stream-module-example
Browse files Browse the repository at this point in the history
Fix the Stream Module example code
  • Loading branch information
wintermeyer authored Jan 26, 2024
2 parents a8087f2 + c5f7210 commit 81005e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/ROOT/pages/elixir/stream.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ list

The `Stream` module can be used with Elixir's pipe operator (`|>`) to create a sequence of transformations. The transformations only get executed when the stream is converted into a list or another enumerable.

This is how you would use `Stream` to multiply each element by 2 and then filter out odd numbers:
This is how you would use `Stream` to multiply each element by 3 and then filter out odd numbers:

[source,elixir]
----
list = [1, 2, 3, 4]
list
|> Stream.map(fn x -> x * 2 end)
|> Stream.map(fn x -> x * 3 end)
|> Stream.filter(fn x -> rem(x, 2) == 0 end)
|> Enum.to_list()
# => [4, 8]
# => [6, 12]
----

[[commonly-used-stream-functions]]
Expand Down

0 comments on commit 81005e0

Please sign in to comment.