Another possible bug?
cljs.user=> (reversible? (seq [1 2 3]))
true
Clojure JVM says this is false (seqs aren’t reversible). Only vectors seem to have this issue in CLJS. When you wrap other reversible things in a seq, the seq stays non-reversible:
cljs.user=> (reversible? [1 2 3])
true
cljs.user=> (reversible? (seq [1 2 3]))
true
cljs.user=> (reversible? (sorted-map))
true
cljs.user=> (reversible? (seq (sorted-map)))
false
cljs.user=> (reversible? (array-map))
false
cljs.user=> (reversible? (seq (array-map)))
falseThis is interesting:
cljs.user=> (type (seq [1 2 3]))
cljs.core/IndexedSeq
but
cljs.user=> (type (seq (sorted-map)))
nil
cljs.user=> (type (seq (sorted-set)))
nil
is odd.seq on any empty coll is nil?
Ah! Right. Of course. And nil is its own type.
I'm not sure the above is a bug, there are some slight difference for sure with the implementation details. If IndexedSeq is reversible then that is correct.
user=> (reversible? (seq [1 2 3]))
false
In CLJ/JVM@dnolen, yea, that’s the conclusion that I was coming to last night as I was playing with it. It looks like CLJS converts a cljs.core/IndexedSeq to a reversible seq (`cljs.core/RSeq`) that Clojure JVM doesn’t have (maybe it should?). So, it doesn’t seem like a bug. This was an interesting progression of types being returned, however, as one reverses each of the seqs:
cljs.user=> (type (seq [1 2 3]))
cljs.core/IndexedSeq
cljs.user=> (type (reverse (seq [1 2 3])))
cljs.core/RSeq
cljs.user=> (type (reverse (reverse (seq [1 2 3]))))
cljs.core/List
cljs.user=> (type (reverse (reverse (reverse (seq [1 2 3])))))
cljs.core/List
cljs.user=> (reversible? (reverse (seq [1 2 3])))
false
cljs.user=> (reversible? (reverse (reverse (seq [1 2 3]))))
false
cljs.user=> (reversible? (reverse (reverse (reverse (seq [1 2 3])))))
false
Everything sort of devolves into cljs.core/List. I’d sort of expect that if you can reverse an IndexedSeq, that it would be reversible? again. But that seems to be lost and eventually you just get a plain ol’ list.
Anyway, not a bug, I think. Just a difference.