Sequences Without End
As we saw in the last chapter, the useful thing about sequences is that they are abstract. Instead of being a linked list or an array or some other definite kind of collection, a seq captures the idea of a sequential collection. A sequence is a thing that will give you the first value when you call first, and another sequence—representing the remaining contents—when you call rest or next. That is pretty much it.
Now consider that sequences are defined in terms of function calls. You can get the lead item in your sequence by calling the first function and a sequence representing the remaining items by calling another function, either next or (more likely) rest. We’ve seen how we can take advantage of the function-driven nature ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access