O'Reilly logo

Clojure High Performance Programming by Shantanu Kumar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sequences and laziness

 

"A seq is like a logical cursor."

 
 --Rich Hickey

Sequences (commonly known as seqs) are a way to sequentially consume a succession of data. Like Java iterators, they let a user begin consuming elements from the head and proceed realizing one element after another. However, unlike Java iterators, sequences are immutable. Also, since sequences are only a view of the underlying data, they do not modify the storage structure of the data.

What makes sequences stand apart is they are not data structures per se; rather, they are a data abstraction over a stream of data. The data may be produced by an algorithm or a data source connected to an I/O operation. For example, the function resultset-seq accepts a JDBC java.sql.ResultSet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required