Stupid way to create a stream

54 views
Skip to first unread message

Robert Dober

unread,
Jul 27, 2016, 3:10:44 AM7/27/16
to elixir-l...@googlegroups.com
Hi list

I was just asking myself for the nth time, how come I need to write things like

          ...
          |> Stream.map(&(1))  
   

Did I completely miss out on my search for something like Enum.to_stream, or does no such thing exist. In the latter case I might think it would be a nice addition to Elixir.

Thx
Robert
--
Non datemi consigli che so sbagliare da solo
(Giuseppe Di Stefano)

Michał Muskała

unread,
Jul 27, 2016, 3:30:23 AM7/27/16
to elixir-l...@googlegroups.com
What do you mean by "convert enum to a stream"? All stream/enum functions accept any enumerable - in fact there’s no one thing you could call “a stream” - all could have a different representation. What’s important is how they implement the enumerable protocol.

Michał.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CA%2Bvts6sULHteH%2B5VDS9Wijb600iFDojDiVZsjOP7HrjRMks0eA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Alexei Sholik

unread,
Jul 27, 2016, 3:30:45 AM7/27/16
to elixir-l...@googlegroups.com
Functions in Enum and Stream take any enumerable. So whatever it is you're doing after the call to Stream.map(& &1) should work even with that call removed.

Robert Dober

unread,
Jul 29, 2016, 5:44:49 AM7/29/16
to elixir-lang-talk
Thank you both, I was looking at that the wrong way. I cannot magically make a stream from en explicit list, I can only process it as a stream.
Reply all
Reply to author
Forward
0 new messages