Re: Question about seq

2010-01-15 Thread Stephen C. Gilardi
On Jan 15, 2010, at 4:01 AM, Stephen C. Gilardi wrote: > On Jan 15, 2010, at 3:26 AM, Sean Devlin wrote: > >> user=> (seq []) >> nil >> >> Why is nil returned, instead of an empty sequence? > > There is no such thing as an empty seq. This was true at one time, but isn't true after the changes

Re: Question about seq

2010-01-15 Thread Adrian Cuthbertson
Hi Sean, The background to this lies in the implementation of lazy sequences - seq returns an implementation of ISeq for the data structure in question - nil when there are no elements in the structure. Have a look at http://clojure.org/sequences and also http://clojure.org/lazy which gives the fu

Re: Question about seq

2010-01-15 Thread Stephen C. Gilardi
On Jan 15, 2010, at 3:26 AM, Sean Devlin wrote: > user=> (seq []) > nil > > Why is nil returned, instead of an empty sequence? It's fundamental to Clojure's seq abstraction that every seq has a first. There is no such thing as an empty seq. If you call the seq function on an empty collection,

Re: Question about seq

2010-01-15 Thread Laurent PETIT
Hey, I guess because a sequence is not a datastructure. If there is nothing to iterate over via 'first or 'next, then it's nil. And an "empty sequence" is precisely that: nil. In my point of view, a sequence is more like a "functional iterator": calling first on it will always return the same va

Question about seq

2010-01-15 Thread Sean Devlin
Hey everyone, I was working with seq today, and I was wondering why I got a certain result. user=> (seq []) nil Why is nil returned, instead of an empty sequence? Sean -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email