liveBook · Manning

Chunk-next

As explained in Clojure: The Essential Reference

chunk-next is a Clojure function that returns the remainder of a chunked sequence after removing its first chunk, or nil when none remains.

chunk-next returns the remainder of a chunked sequence after removing its first chunk, or nil when no chunk remains. It belongs to the chunk-* family, which supports chunked sequential processing and can improve performance for suitable data sources. section 10.12

Use chunk-next with these practical boundaries in mind:

  • The input is a chunked sequence s, recognized by chunk-seq?. section 10.12
  • The result is the sequence after its first chunk, or nil when no remainder exists. section 10.12
  • Treat chunk-next and related chunk-* functions as low-level tools: they were publicized for experimentation while labeled implementation details. section 10.12
Listing 10.13. → Chunked sequences
(chunk-cons [chunk rest])
(chunk-first [s])
(chunk-rest [s])
(chunk-next [s])

(chunk-buffer [capacity])
(chunk-append [b x])
(chunk [b])
(chunked-seq? [s])

Browse the compact chunked-sequence API listing to compare chunk-next with chunk-cons, chunk-first, and chunk-rest. section 10.12

How Clojure: The Essential Reference covers it

How deep it goes
Defines the input and return behavior, but stops short of implementation details for chunk-next itself.
Examples
Shows chunk-next alongside the chunked-sequence API listing, while detailed construction examples use chunk-cons and chunk-rest.
What it assumes
Assumes familiarity with sequential collections and chunked sequences, including the chunk-seq? predicate.
What you can do after
Apply chunk-next as a drop-in sequence operation when traversing a chunked sequence.
How it connects
Connects chunk-next with chunked sequences, lazy sequences, chunk-first, chunk-rest, and chunk-cons.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.