We're updating the issue view to help you get more done. 

operation on the sorted-set fails under certain conditions

Description

Function generates a sequence of prime numbers. Uses a priority queue implemented as a sorted set of vectors [priority val].

On the iteration (x = 10) fails with message:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (defn sieve [[x & t] pq] (lazy-seq (if (or (empty? pq) (< x (ffirst pq))) (cons x (sieve t (conj pq [(* x x) (next (iterate (partial + x) (* x x)))]))) (sieve t (loop [pq pq] (let [[key val :as head] (first pq)] (if (= x key) (recur (conj (disj pq head) [(first val) (next val)])) pq) )))))) (def primes (sieve (iterate inc 2) (sorted-set))) (take 4 primes) ;; => (2 3 5 7) (take 5 primes) ClassCastException clojure.lang.Iterate cannot be cast to java.lang.Comparable clojure.lang.Util.compare (Util.java:153)

When x = 10 it goes to the (loop ...) section and fails while trying to recur.

Environment

Windows 8.1

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

None

Patch

None

Affects versions

Release 1.7

Priority

Major