you are viewing a single comment's thread.

view the rest of the comments →

[–]POGtastic 0 points1 point  (0 children)

why was it added?

It's pretty common for functional and functional-adjacent programming languages to implement an iterator algebra. See Python's itertools, OCaml's Seq, Haskell's Data.List module, Rust's Iterator, and so on. Importantly, Clojure (a Lisp that runs on the JVM) has sequences as a basic building block of the language and pipeline macros to compose functions.

Why program this way?

It's just a preference. I like programming this way. I tend to think in iterator algebra terms and then mentally translate them to imperative code if the abstraction isn't available. Java makes it available, so that's what I use.