A Rich Toolkit …

If all we were talking about was first and rest, this whole sequence kerfuffle wouldn’t amount to much. The real power of sequences lies in the mountain of useful library functions that—like our my-count function—take any kind of collection, convert it to a sequence, and then do something interesting with the sequence. For example, if you have a seqable collection but it’s in the wrong order, you can sort it with sort:

 (​def​ titles [​"Jaws"​ ​"Emma"​ ​"2001"​ ​"Dracula"​])
 
 (sort titles) ​; Sequence: ("2001" "Dracula" "Emma" "Jaws")

Like count, sort converts the collection you pass in into a sequence, sorts it, and returns the resulting sequence.

Seqa What?

Yes, seqable is a word, at least if you are a Clojurist. A seqable ...

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.