Re: Understanding sequence abstraction

2010-06-01 Thread Richard Newman
Because seq is defined as returning nil for an empty sequence. The only way to find that out for a lazy sequence is to realize the first element. I'm not sure if that answers why seq should realize the first element. Even by what you say, only if I wanted to find if my LazySeq was nil should I

Re: Understanding sequence abstraction

2010-05-31 Thread ka
@Richard >> 1. In case coll is a LazySeq why does (seq coll) realize its first >> element? I thought seq just did a type conversion and all of list, >> vector .. etc implemented Seqable or something. > Because seq is defined as returning nil for an empty sequence. The > only way to find that out

Re: Understanding sequence abstraction

2010-05-30 Thread Joost
On May 30, 8:11 pm, Richard Newman wrote: > > 2. Why is there no other way to determine an empty coll except (not > > (seq coll)). > > user=> (empty? []) > true And in fact, the docs for (empty?) say: "Please use the idiom (seq x) rather than (not (empty? x))" Perhaps the seq docs should indi

Re: Understanding sequence abstraction

2010-05-30 Thread Richard Newman
1. In case coll is a LazySeq why does (seq coll) realize its first element? I thought seq just did a type conversion and all of list, vector .. etc implemented Seqable or something. Because seq is defined as returning nil for an empty sequence. The only way to find that out for a lazy sequenc

Understanding sequence abstraction

2010-05-30 Thread ka
Hi Clojurians, I have some conceptual questions on the sequence abstraction. I understand that (seq coll) will give me a "sequence". coll maybe be a list, vector, map, set, LazySeq or nil. 1. In case coll is a LazySeq why does (seq coll) realize its first element? I thought seq just did a type