drop removes the first n elements from a sequential input and returns the remaining sequence. With only n, it returns a transducer that skips the first n inputs during reduction. section 10.2 section 7.2
Its contract is compact but includes useful edge cases:
- Provide n and coll for a sequence result, or provide only n for a transducer. section 10.2
- Treat negative n as zero; accept zero, fractional, and other numeric values as permitted by the contract. section 10.2
- Return an empty sequence when n exceeds the collection length, and reject a non-sequential coll with IllegalArgumentException. section 10.2
- Compose the transducer with other transformations; it prevents the reducing function from receiving the first n elements. section 7.2
Skipping a prefix
(drop 3 (range 10)) ;; (3 4 5 6 7 8 9) (transduce (comp (drop 3) (map inc)) + (range 10)) ;; 49 The first form returns the tail after three elements; the second skips three inputs before applying map and reducing. section 10.2
Lazy traversal
When applied to a lazy input, drop does not necessarily realize the result immediately: (def time-bomb (drop 1e7 (xs))) creates the value without the visible traversal performed by eager operations.
