You are right demanding a base case. I don't deny that any more. As stated 
above, me as a beginner, experimenting for experience, took the well-known 
Fibonacci corecursion (with base case) as guidance in setting my first 
prime corecursion code with range, and then reduced the base case from '(2 
3 5) to '(2 3) realizing that it didn't work any longer. Then finding that 
with "iterate" it did. Then further reduced to '(2) and '(), finding that 
it still worked. What clojure version are you using btw to get the 
exceptions? I never got those exceptions but the correct result (tried with 
1.2, 1.3 and 1.4). So thought with '() everything is still fine, so thought 
I can omit the whole concat. This was seconded from a mathematical point of 
view: the only subset S from X=[2,3,4,...] where each n is included, if it 
has no divisor in {m in S: m*m<=n} is THE sequence of primes. But of course 
clojure won't be able (yet :) ) to logically deduce this relation simply by 
evaluating the corecursion code. And simple calculation run into problems 
while evaluating "take-while". With a base case "take-while" will return 
properly.

Now, that's clear, anyway, the main point was and still is,
that the code (the version corrected with a base case)

(def primes
  (cons
    2
    (filter
      (fn[n]
        (every?
          #(pos? (mod n %))
          (take-while #(<=(*%%)n) primes)
          )
        )
      (drop 3 (range))
      )
    )
  )


SHOULD imho properly work in a proper clojure implementation,
n'est ce pas?

If it doesn't because of internal!!! representation
of the involved sequences,
be it chunked or something else,
than this is a huge pitfall,
which might be hard to detect
in more complicated structures.

Now should we consider this a clojure bug?

Ulrich.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to