On Thu, Feb 3, 2011 at 1:31 PM, Meikel Brandmeyer <m...@kotka.de> wrote: > Hi, > > On 3 Feb., 08:04, Petr Gladkikh <petrg...@gmail.com> wrote: > >> Should not it be empty colection instead? >> It seems odd to me since it is inconsistent and forces to consider one >> more case (nil or collection). > > It is consistent. There is a difference between () and nil. () is the > empty list. However there is no "empty sequence." Either there is > something or there is nothing. Why would you have to check for nil? > You can pass nil to any of the sequence library functions without fear > of harm. When you write such a function yourself, there is usually a > single check in the beginning when realising the sequence. Something > like (when-let [s (seq coll)] ...). > > I never encountered any problems with this. Do you have a concrete > example where this causes trouble for you?
I have a vector that holds some history. I conj new items to it and to save space I'd like to retain not more than n last items. To do that I used (take-last n history). So: [] -> (take-last n []) -> nil -> (conj nil newItem) -> '(newItem) But list conj's at the beginning not at end of sequence as I would like to. Of course I could use () from the beginning (with account for reverse order). But with [] I should do little more. -- Petr Gladkikh -- 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