concept rsubseq in category clojure

appears as: rsubseq
Clojure: The Essential Reference

This is an excerpt from Manning's book Clojure: The Essential Reference.

  • subseq and rsubseq produce a sequence from parts of a sorted collection, such as sorted-set or sorted-map.
  • subseq and rsubseq create a sequence out of the elements enclosed by a lower/upper bound in a sorted collection:

    (subseq (apply sorted-set (range 10)) > 2 < 8) ; #1
    ;; (3 4 5 6 7)
    
    (rsubseq (apply sorted-map (range 10)) <= 5)   ; #2
    ;; ([4 5] [2 3] [0 1])

    rsubseq differs from subseq in the order the sequence is generated: from the first matching element (subseq) or from the last (rsubseq). subseq and rsubseq implicitly require the input collection to support a notion of ordering, which restricts the possible input types to sorted-set and sorted-map.