TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Elixir Streams

152 pointsby pgr0ssalmost 10 years ago

3 comments

phamiltonalmost 10 years ago
When people say Elixir is just syntactic sugar on top of erlang I point them to Stream and Enum. It's a great example of how polymorphism via protocols is an enabler for powerful designs.
评论 #9683955 未加载
doomroboalmost 10 years ago
Interesting to see this as a novel thing in another ecosystem. Rust actually uses &quot;stream&quot; manipulation as a default way of dealing with things that might otherwise be expressed as full data structures. For example, the equivalent to one of the code snippets in the article would be:<p>BufReader::new(File::open(&quot;myfile.txt&quot;).unwrap())<p>.lines()<p>.enumerate()<p>.map(|(i, line)| format!(&quot;{}: {}&quot;, i, line.unwrap()))<p>.take(1)<p>.next().unwrap()<p>(formatted for non-monospace font readability). Note the .unwrap() is where error handling should normally happen.
评论 #9683586 未加载
_nato_almost 10 years ago
I wonder what the Erlang equivalent would look like (passing around data that are funs)?
评论 #9682543 未加载
评论 #9683415 未加载