This chapter is about functions and macros for sequential processing. These functions typically transform their input into a sequence (if it’s not already) and produce another sequence. Although sequential functions can be used with any collection type offering a sequential interface, they tend to perform at their best with pure sequential input/output.
Sequential processing can be broadly categorized as follows:
- Splitting: isolate a consecutive portion of the sequence by index, number of items, or using a custom predicate. Functions like split belong to this group, and also drop, rest and their variations.
- Selection: retrieve specific items from the sequence but not necessarily as a consecutive selection, for example take-nth or filter.
- Transformation: apply a function to each item in the sequence to produce another sequence, like map, keep or mapcat.
- Combining: combination of multiple sequences to form another sequence, like interpose or concat.
- Chunking: process a sequence by groups of multiple elements instead of one at a time. Clojure provides a small API to create chunked sequences described in the chunk-cons section.
Some functions like first , map or filter also belong here, but they have given specific emphasis in the "Basic Constructs" chapter.
functions
since 1.0