Fork me on GitHub
#beginners
<
2018-06-28
>
dguay11:06:39

Why I get this error java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn on this --> (list "string1" "string2")

dguay11:06:50

even (list 1 2 3) gives the same error in my REPL

mfikes12:06:50

@d.guay What do you get if you evaluate list. (Is it a string?) Thinking that you may have done something like (def list "abc")

dguay12:06:18

you're right

Jeremy21:06:13

Hi folks. I'm using Cursive with its lein repl integration. Everything works great except the repl prompt doesn't show the namespace. I can't work out how to configure/investigate this.

Jeremy21:06:44

Oopsie—found the :repl-options :prompt setting. I was just confused that it didn't default to showing the ns.

johnj21:06:47

why is this true? (list? (rest '(1 2 3 4)))

johnj21:06:49

does rest doesn't call seq on lists?

noisesmith21:06:11

user=> (list? (seq '(1 2)))
true

noisesmith21:06:31

seq isn't a concrete type, there's a few kinds of things that are seqs

johnj22:06:03

so lists are no part of the seq abstraction? internally wise

noisesmith22:06:09

like I said, seq's are abstract. Lists are seqs.

noisesmith22:06:24

specifically, they are objects that extend ISeq

noisesmith22:06:18

user=> (supers (class '(1 2)))
#{clojure.lang.IReduce clojure.lang.IPersistentList clojure.lang.IObj clojure.lang.IPersistentStack clojure.lang.ISeq clojure.lang.Seqable clojure.lang.IMeta clojure.lang.IReduceInit java.lang.Iterable java.util.List clojure.lang.IHashEq java.lang.Object clojure.lang.Obj java.util.Collection clojure.lang.Counted clojure.lang.Sequential clojure.lang.ASeq clojure.lang.IPersistentCollection java.io.Serializable}

noisesmith22:06:58

Those are all of the parent classes of a list. Anything implementing clojure.lang.ISeq is a seq.

johnj22:06:16

got it, what else implements ISeq directly like lists?

johnj22:06:51

and seqs hehe

👏 4
noisesmith22:06:29

there's a few things - there's no specific thing that's a seq - a seq is a name for anything which implements ISeq - for example lazy-seq which is created by map, filter, etc. is a seq