liveBook · Manning

Nnext

As explained in Clojure: The Essential Reference

nnext is a Clojure function that returns the sequence obtained after removing the first two elements, or nil when no such sequence exists.

nnext returns the sequence after removing the first two elements from a collection. It accepts any seqable input or nil and returns nil when no such sequence exists. section 10.1

Basic behavior

(nnext '(0 1 2 3)) ;; (2 3) ((juxt nnext) nil) ;; [nil] (nnext []) ;; nil

Use nnext when the desired operation is the compact composition of next and next:

  • In recursive sequence processing, combine first with nnext when examining an item while advancing past two positions. section 10.1

How Clojure: The Essential Reference covers it

How deep it goes
Defines two-element removal, seqable inputs, and nil edge cases through comparative examples.
Examples
Uses quoted sequences, nil, empty collections, juxt, and neighboring records in a lazy message processor.
What it assumes
Assumes familiarity with seqable collections, nil, first, next, and lazy sequence processing.
What you can do after
Apply it via Clojure sequence operations when two leading elements must be skipped.
How it connects
Connects nnext with next, rest, first, sequence recursion, and lazy sequence processing.

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.