I second: using seq to test for emptiness is only one half of the idiom, the second half is to bind and to destructure (usually with if-let) the returned value.
Christophe On Sat, May 11, 2013 at 12:08 PM, Chris Ford <christophertf...@gmail.com>wrote: > IMHO it's a bit subjective, but empty? is defined as (not (seq coll)), so > using (not (empty? coll)) is really saying (not (not (seq coll))), which > feels a bit backwards. > > Using seq also plays nicely with if-let: > > (if-let [foo (seq "hey")] (print foo)) > (if-let [foo (seq "")] (print foo)) > > Chris > > > On 11 May 2013 12:48, Kelker Ryan <theinter...@yandex.com> wrote: > >> Here's an example. >> >> user=> (if (seq []) (println 1)) >> nil >> user=> (if (seq [1]) (println 1)) >> 1 >> nil >> >> >> 11.05.2013, 18:40, "Kelker Ryan" >> > (seq coll) will return a true value if the collection isn't empty. It >> will also return nil (false) if it is. >> > >> > 11.05.2013, 17:37, "Nico Balestra" <nicobales...@gmail.com>: >> > >> >> I'm not sure this question has been asked already, but I really want >> to know the "principle" behind (not (empty? coll)) not being idiomatic. >> >> >> >> I find it much more readable than (seq coll) and I don't understand >> why (empty?) exists if it's not idiomatic. But my real doubt is: >> >> >> >> What's the "idiom" in (seq coll)? >> >> >> >> Thanks and sorry if the question sounds a bit pedantic :) >> >> >> >> Nico >> >> >> >> "It is better to have 100 functions operate on one data structure >> than to have 10 functions operate on 10 data structures" - A.J. Perlis >> >> >> >> -- >> >> -- >> >> 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/groups/opt_out. >> > >> > -- >> > -- >> > 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/groups/opt_out. >> >> -- >> -- >> 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/groups/opt_out. >> >> >> > -- > -- > 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/groups/opt_out. > > > -- On Clojure http://clj-me.cgrand.net/ Clojure Programming http://clojurebook.com Training, Consulting & Contracting http://lambdanext.eu/ -- -- 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/groups/opt_out.