Perhaps you can replace (reduce ...) with (every? true?), which works with empty collections.
On Tue, Nov 3, 2015 at 6:05 PM, Timur <[email protected]> wrote: > Hi all, > > Often I need to make decisions in simple threading macros, for instance > consider the following code > > (->> m > :vector > (filterv #(= (:id %) (:id m))) > (reduce #(and %1 %2))) > > In this case, if the result of filter is empty reduce throws an exception > as it expects some values. Therefore, I want to include a decision between > filter and reduce for instance if empty then add false into the resulting > vector. What would be the best way to achieve this? I could add a function > that checks if empty then add sth into the vector but wanted to ask your > opinions if there is a better way to do this. > > Regards, > > Timur > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Kind Regards, Atamert Ölçgen ◻◼◻ ◻◻◼ ◼◼◼ www.muhuk.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
