Re: chunked-seq? is lying?

2010-12-31 Thread Chas Emerick

On Dec 31, 2010, at 5:53 PM, Mike K wrote:

> OK, I understand the difference in behavior between the two maps.  But
> why is chunked-seq? incorrect?
> 
> Also, Chas Emerick stated in another discussion that ranges always
> produce chunked seqs, but the value of (chunked-seq? (range 100))
> seems to belie that.

I was being a little loose in my description.  Ranges always produce chunked 
seqs via seq:

=> (chunked-seq? (range 10))
false
=> (chunked-seq? (seq (range 10)))
true

`range` returns a lazy seq, which "guards" the chunked seq.  Lazy seqs are 
never chunked themselves (otherwise, "proper" laziness would never be possible) 
but the seqs they provide are always aligned with the chunkiness of whatever 
lies beneath the lazy seq:

=> (chunked-seq? (seq (lazy-seq '(1 2 3
false
=> (chunked-seq? (seq (lazy-seq [1 2 3])))
true

- Chas

-- 
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


Re: chunked-seq? is lying?

2010-12-31 Thread Mike K
OK, I understand the difference in behavior between the two maps.  But
why is chunked-seq? incorrect?

user> (take 1 (map #(do (print ".") [%]) (range 100)))
([0])
user> (chunked-seq? (range 100))
false
user> (chunked-seq? (map #(do (print ".") [%]) (range 100)))
false
user> (chunked-seq? (take 1 (map #(do (print ".") [%]) (range 100
false

The implementation of chunked-seq? checks to see if the sequence is an
instance of clojure.lang.IChunkedSeq.  That doesn't appear to be
sufficient in the case of map taking one collection.

Also, Chas Emerick stated in another discussion that ranges always
produce chunked seqs, but the value of (chunked-seq? (range 100))
seems to belie that.


  Mike

-- 
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


Re: chunked-seq? is lying?

2010-12-31 Thread Meikel Brandmeyer
Hi,

Am 31.12.2010 um 19:57 schrieb Mike K:

> In 1.2, I don't understand why one of the sequences below is chunked,
> but the other is not.  Also, chunked-seq? seems to be lying about the
> second one.
> 
> user> (take 1 (map #(do (print ".") [% %2]) (range 100) (range 100)))
> (.[0 0])
> user> (take 1 (map #(do (print ".") [%]) (range 100)))
> ([0])
> user> (chunked-seq? (map #(do (print ".") [%]) (range 100)))
> false

For map with multiple input sequences all sequences would probably be have to 
be chunked with the same chunk size. So instead of checking this, map produces 
for multiple input sequences a non-chunked seq.

Sincerely
Meikel

-- 
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


chunked-seq? is lying?

2010-12-31 Thread Mike K
In 1.2, I don't understand why one of the sequences below is chunked,
but the other is not.  Also, chunked-seq? seems to be lying about the
second one.

user> (take 1 (map #(do (print ".") [% %2]) (range 100) (range 100)))
(.[0 0])
user> (take 1 (map #(do (print ".") [%]) (range 100)))
([0])
user> (chunked-seq? (map #(do (print ".") [%]) (range 100)))
false

   Mike




-- 
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