3 ms·
Why waste such a powerful term as "stream" on good old trivial 'list comprehensions'? https://en.wikipedia.org/wiki/List_comprehension https://en.wikipedia.org
by Dudester230602 3y ago
Why waste such a powerful term as "stream" on good old trivial 'list comprehensions'?
https://en.wikipedia.org/wiki/List_comprehension https://en.wikipedia.org/wiki/List_comprehension
- xienze 3y agoBecause it applies to things other than lists?
- Dudester230602 3y agoAre you making an assumption based on some specific "lists" or are Java 'streams' infinite? https://en.wikipedia.org/wiki/List_(abstract_data_type) https://en.wikipedia.org/wiki/List_(abstract_data_type) https://en.wikipedia.org/wiki/Stream_(abstract_data_type) https://en.wikipedia.org/wiki/Stream_(abstract_data_type)
- mrkeen 3y ago> or are Java 'streams' infinite? They are in toy examples. I don't follow your original point 100%, but I will say that 90% of the time when I use Streams, I'm really just wishing List had map and filter, etc.
- tpm 3y agoJava Streams apply to Collections, which is a broader abstraction than a list.
- Sankozi 3y ago"A list comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists." (https://en.wikipedia.org/wiki/List_comprehension https://en.wikipedia.org/wiki/List_comprehension) Stream's terminal operations contains much more options than just "creating a list".
- shepherdjerred 3y agoStreams work on any Java Collection, such as Maps.
- vips7L 3y agoMap doesn't implement the Collection interface. https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/Map.java#L163 https://github.com/openjdk/jdk/blob/master/src/java.base/sha...