chunk-rest returns the remainder of a chunked sequence after removing its first chunk. It parallels rest for lazy-sequence processing and returns an empty list when no chunk remains. section 10.12
Use chunk-rest when processing chunked sequences:
- Pass it a chunked sequence, where chunk-seq? returns true. section 10.12
- Pair chunk-first with chunk-rest to transform the current chunk and recursively continue with later chunks. section 10.12
- Treat chunk-* functions as low-level tools for chunked processing rather than general-purpose sequence operations. section 10.12
Continuing a chunked map
A chunked mapping function processes the first chunk, then calls (chunk-rest s) in its recursive step: (chunk-cons (chunk b) (map-chunked f (chunk-rest s))). Taking ten results from (map-chunked inc (range 10000)) produces (1 2 3 4 5 6 7 8 9 10). 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 related chunked-sequence operations, including chunk-rest alongside chunk-cons, chunk-first, and chunk-next. section 10.12
