Thanks, James!

What still throws me off is that the JoC book points out a symmetry that I 
wanted to better grasp. It first notes that:

  * `(first []) ;=> nil` and
  * `(rest []) ;=> ()`

and then goes on to say:

  * "Clojure functions that promise to return sequences, such as `map` and 
`filter`, work the same way as `rest`." And,

  * (when calling `seq` on a coll) "...In either case, if the collection is 
empty, `seq` returns nil and never an empty sequence. Functions that 
promise to return seqs (not sequences), such as `next`, work the same way."

Hm. "seqs (not sequences)" doesn't make sense to me here. Maybe I'm 
misunderstanding, or maybe there's a typo (or mis-capitalization) in there 
somewhere?

-- John



On Wednesday, October 8, 2014 8:16:38 PM UTC-4, James Reeves wrote:
>
> The words "seq" and "sequence" can be used interchangeably.
>
> The "map" and "filter" functions return seqs.
>
> Yes, a seq may be lazy, but vectors and lists cannot.
>
> "seqable" means any data structure that can be turned into a seq using the 
> "seq" function. This includes the Clojure collections, but also strings, 
> arrays and Java collections.
>
> The Sequential interface is a way of indicating a collection has a natural 
> order. So seqs, lists and vectors are sequential, but maps and sets are not.
>
> The ISeq interface is the internal interface for seqs. An object is a seq 
> if it implements ISeq.
>
> - James
>
>
> On 8 October 2014 19:39, John Gabriele <jmg...@gmail.com <javascript:>> 
> wrote:
>
>> Reading Joy of Clojure, section 5.1.2, I'm hoping someone here can help 
>> me understand the following:
>>
>>   * `clojure.core/seq` returns a "seq" or a "sequence"? Likewise for 
>> `map` and `filter`.
>>
>>   * What is the difference between a "seq" and a "sequence"?
>>
>>   * A seq may possibly be lazy, but vectors and lists are always 
>> fully-realized, correct?
>>
>>   * What does "seqable" mean?
>>
>>   * Is Seq (ISeq?) or is Sequential the `first`/`rest` API? What is the 
>> difference between ISeq and Sequential (see `seq?` & `sequential?`)?
>>
>> Thanks!
>>
>>  

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to