Also, I really appreciate anyone who takes the time to answer. My company
is currently evaluating Clojure. I'm trying to determine if this is
non-idiomatic use of the language or some other issue. Doing something like
this can cause the bug to occur without directly calling seq on a vector:
(defn bar [my-list n]
(if (= n 0)
(peek my-list)
(bar (rest my-list) (dec n))))
(bar [1 2 3] 1)
Both rest and peek work on a vector without a problem but the combination
of the two causes problems.
On Thursday, June 20, 2013 3:54:43 PM UTC-4, Jason Gilman wrote:
>
> Why does (peek (seq [1])) result in:
> ClassCastException clojure.lang.PersistentVector$ChunkedSeq cannot be cast
> to clojure.lang.IPersistentStack clojure.lang.RT.peek (RT.java:634)
>
> Peek documentation "For a list or queue, same as first, for a vector, same
> as, but much more efficient than, last. If the collection is empty, returns
> nil." implies that there shouldn't be a problem working with vectors.
>
> This works without issue:
> (peek [1])
>
> This is on Clojure 1.5.1
>
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.