Skip to content

Instantly share code, notes, and snippets.

@diogovk
Created May 12, 2016 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogovk/38be2717d0726a9252583fd3369d9763 to your computer and use it in GitHub Desktop.
Save diogovk/38be2717d0726a9252583fd3369d9763 to your computer and use it in GitHub Desktop.
Zip and Streams demonstration
iex(1)> jump=4
4
iex(2)> s = Stream.unfold(0, fn x -> {x, x+jump} end)
#Function<1.133682015/2 in Stream.unfold/2>
iex(3)> items = [ "aba", "cate", "dood"]
["aba", "cate", "dood"]
iex(4)> Enum.zip(s, items)
[{0, "aba"}, {4, "cate"}, {8, "dood"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment