user=> (cons 1 )
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be
cast to clojure.lang.ISeq
at clojure.lang.AFn.applyToHelper(Unknown Source)
at clojure.lang.AFn.applyTo(Unknown Source)
at clojure.lang.Compiler$InvokeExpr.eval(Unknown Source)
at clojure.lang.Compiler.eval(Unknown Source)
at clojure.lang.Repl.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I rewrote this e-mail several times as I discovered I understood less
and less about collections and sequences than I had thought.
I had understood from the documentation that sequences were a
super-type of collections, and that first and rest operated on
sequences (they are introduced as "the sequence interface"). It seems
it's the other way around, though, as from looking at the code I see
that sequences are a sub-type of collections, and that first and rest
are actually functions on collections (though rest is collection ->
sequence), not necessarily sequences. Am I correct in saying that
sequences are simply collections which can be used with cons? I hear
about sequences in Clojure much more often than I hear about
collections, so it's a little surprising to see this.
Also, returning to my original problem, why does apply only take seqs
as the final argument?
Thanks for the explanation, it makes more sense now =).
> > Also, returning to my original problem, why does apply only take seqs
> > as the final argument?
> There is no good reason - I have fixed this so it takes any collection
> as the last arg (and calls seq on it!) - thanks for the report.