user=> (rseq [:a :b]) (:b :a) user=> (rseq (rseq [:a :b])) ClassCastException clojure.lang.APersistentVector$RSeq cannot be cast to clojure.lang.Reversible clojure.core/rseq (core.clj:1532)
Why rseq n't rseq accept the result of a previous rseq call?
I read in docstring that the argument must be (in fact, "maybe") a vector or sort-map, and the above shows that it cannot be rseq , so I already know that. I want to know: are there any good reasons for this restriction? Is it just oversight, or is this limitation giving some important benefits?
Also, is there a convenient way to do this, other than to never call rseq ? It is hard to understand when you return rseq from one function whether some other function in another place can call rseq on it.
I ask because it is disappointing when my code throws exceptions for such an amazing reason s . If I knew why this made sense, I would be less likely to make this and similar errors.
clojure reverse sequence rationale
Ben kovitz
source share